File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 4
4
// on `None`. Handle this in a more graceful way than calling `unwrap`!
5
5
// Scroll down for hints :)
6
6
7
- fn main ( ) {
7
+ pub fn pop_too_much ( ) -> bool {
8
8
let mut list = vec ! [ 3 ] ;
9
9
10
10
let last = list. pop ( ) . unwrap ( ) ;
@@ -15,9 +15,18 @@ fn main() {
15
15
"The second-to-last item in the list is {:?}" ,
16
16
second_to_last
17
17
) ;
18
+ true
18
19
}
19
20
21
+ #[ cfg( test) ]
22
+ mod tests {
23
+ use super :: * ;
20
24
25
+ #[ test]
26
+ fn should_not_panic ( ) {
27
+ assert ! ( pop_too_much( ) , true ) ;
28
+ }
29
+ }
21
30
22
31
23
32
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ mode = "test"
192
192
193
193
[[exercises ]]
194
194
path = " exercises/error_handling/option1.rs"
195
- mode = " compile "
195
+ mode = " test "
196
196
197
197
[[exercises ]]
198
198
path = " exercises/error_handling/result1.rs"
You can’t perform that action at this time.
0 commit comments