gistlib
main.rsfn my_function() -> Result<i32, &'static str> { if some_condition { Ok(42) } else { Err("Something went wrong") } } #[cfg(test)] mod tests { use super::*; #[test] fn test_my_function_success() { assert_eq!(my_function(), Ok(42)); } #[test] fn test_my_function_failure() { assert_eq!(my_function(), Err("Something went wrong")); } } 407 chars23 lines
fn my_function() -> Result<i32, &'static str> { if some_condition { Ok(42) } else { Err("Something went wrong") } } #[cfg(test)] mod tests { use super::*; #[test] fn test_my_function_success() { assert_eq!(my_function(), Ok(42)); } #[test] fn test_my_function_failure() { assert_eq!(my_function(), Err("Something went wrong")); } }
gistlibby LogSnag