diff options
| author | mo8it <mo8it@proton.me> | 2024-04-17 23:34:27 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-04-17 23:34:27 +0200 |
| commit | 2f810a4da67233716ad93e00afff6e8b260f4807 (patch) | |
| tree | f5a33357141d25d08b6726910efe33f2338b9cdb /exercises/13_error_handling/errors4.rs | |
| parent | cb9f1ac9ce3c834b0cca964b6809b74508f80b54 (diff) | |
Clean up and unify exercises
Diffstat (limited to 'exercises/13_error_handling/errors4.rs')
| -rw-r--r-- | exercises/13_error_handling/errors4.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/exercises/13_error_handling/errors4.rs b/exercises/13_error_handling/errors4.rs index 9449417..993d42a 100644 --- a/exercises/13_error_handling/errors4.rs +++ b/exercises/13_error_handling/errors4.rs @@ -1,8 +1,3 @@ -// errors4.rs -// -// Execute `rustlings hint errors4` or use the `hint` watch subcommand for a -// hint. - #[derive(PartialEq, Debug)] struct PositiveNonzeroInteger(u64); @@ -23,12 +18,17 @@ fn main() { // You can optionally experiment here. } -#[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)); +#[cfg(test)] +mod tests { + use super::*; + + #[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)); + } } |
