Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion exercises/error_handling/option1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// on `None`. Handle this in a more graceful way than calling `unwrap`!
// Scroll down for hints :)

fn main() {
pub fn pop_too_much() -> bool {
let mut list = vec![3];

let last = list.pop().unwrap();
Expand All @@ -15,9 +15,18 @@ fn main() {
"The second-to-last item in the list is {:?}",
second_to_last
);
true
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn should_not_panic() {
assert!(pop_too_much(), true);
}
}



Expand Down
2 changes: 1 addition & 1 deletion info.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ mode = "test"

[[exercises]]
path = "exercises/error_handling/option1.rs"
mode = "compile"
mode = "test"

[[exercises]]
path = "exercises/error_handling/result1.rs"
Expand Down