summaryrefslogtreecommitdiff
path: root/exercises/error_handling/result1.rs
diff options
context:
space:
mode:
authorTaylor Yu <tlyu@mit.edu>2021-06-06 20:14:29 -0500
committerTaylor Yu <tlyu@mit.edu>2021-06-06 23:08:54 -0500
commit50ab289da6b9eb19a7486c341b00048c516b88c0 (patch)
tree162c10c44aa5119007c8b7d958d2806a6cb07ed7 /exercises/error_handling/result1.rs
parenta2f0401c4c4be9ac326714f55fee454db22c0862 (diff)
fix: rename result1 to errors4
Also put it in the ERROR HANDLING section where it probably belongs.
Diffstat (limited to 'exercises/error_handling/result1.rs')
-rw-r--r--exercises/error_handling/result1.rs29
1 files changed, 0 insertions, 29 deletions
diff --git a/exercises/error_handling/result1.rs b/exercises/error_handling/result1.rs
deleted file mode 100644
index b978001..0000000
--- a/exercises/error_handling/result1.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// result1.rs
-// Make this test pass! Execute `rustlings hint result1` for hints :)
-
-// I AM NOT DONE
-
-#[derive(PartialEq, Debug)]
-struct PositiveNonzeroInteger(u64);
-
-#[derive(PartialEq, Debug)]
-enum CreationError {
- Negative,
- Zero,
-}
-
-impl PositiveNonzeroInteger {
- fn new(value: i64) -> Result<PositiveNonzeroInteger, CreationError> {
- Ok(PositiveNonzeroInteger(value as u64))
- }
-}
-
-#[test]
-fn test_creation() {
- assert!(PositiveNonzeroInteger::new(10).is_ok());
- assert_eq!(
- Err(CreationError::Negative),
- PositiveNonzeroInteger::new(-10)
- );
- assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
-}