2 releases

0.1.1 Nov 15, 2021
0.1.0 Sep 21, 2021

#2958 in Rust patterns

MIT/Apache

8KB
196 lines

Soft Assertions

This library provides soft, non-panicking assertions. Instead, the assertions provided by this crate return a Result. To use this crate, simply replace assert!(...) by soft::assert!(...)?.

Example

fn main() {
    soft::panic!(false).unwrap_err();

    soft::assert!(true).unwrap();
    soft::assert!(false).unwrap_err();

    soft::assert_eq!(2, 2).unwrap();
    soft::assert_eq!(2, 3).unwrap_err();
    
    soft::assert_ne!(2, 3).unwrap();
    soft::assert_ne!(2, 2).unwrap_err();
}

No runtime deps