DeveloperBreeze

Rust Testing Development Tutorials, Guides & Insights

Unlock 1+ expert-curated rust testing tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your rust testing skills on DeveloperBreeze.

Cheatsheet
rust

Rust Cheatsheet

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }

    #[test]
    fn another() {
        panic!("This test will fail");
    }
}
fn divide(dividend: f64, divisor: f64) -> Result<f64, String> {
    if divisor == 0.0 {
        Err(String::from("Cannot divide by zero"))
    } else {
        Ok(dividend / divisor)
    }
}

Aug 29, 2024
Read More