summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exercises/error_handling/option1.rs11
-rw-r--r--info.toml2
2 files changed, 11 insertions, 2 deletions
diff --git a/exercises/error_handling/option1.rs b/exercises/error_handling/option1.rs
index 13fc720..d96a871 100644
--- a/exercises/error_handling/option1.rs
+++ b/exercises/error_handling/option1.rs
@@ -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();
@@ -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);
+ }
+}
diff --git a/info.toml b/info.toml
index 6c4f639..d7f86f9 100644
--- a/info.toml
+++ b/info.toml
@@ -192,7 +192,7 @@ mode = "test"
[[exercises]]
path = "exercises/error_handling/option1.rs"
-mode = "compile"
+mode = "test"
[[exercises]]
path = "exercises/error_handling/result1.rs"