#[cfg(test)] mod tests { #[test] fn result_test() -> Result<(), String> { if 2 + 2 == 4 { Ok(()) } else { Err(String::from("two plus two does not equal four")) } } #[test] fn assert_use() { assert_eq!(2+2,4) } use super::*; #[test] #[should_panic] fn greater_than_100() { Guess::new(200); } } pub struct Guess { value: i32, } impl Guess { pub fn new(value: i32) -> Guess { if value < 1 || value > 100 { panic!("Guess value must be between 1 and 100, got {}.", value); } Guess { value } } }