soft

Crates.iosoft
lib.rssoft
version0.1.1
sourcesrc
created_at2021-09-21 12:42:57.759274
updated_at2021-11-15 10:54:50.714941
descriptionProvides soft, non-panicking assertions.
homepage
repositoryhttps://github.com/fabianboesiger/soft
max_upload_size
id454382
size8,687
Fabian Bösiger (fabianboesiger)

documentation

README

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();
}
Commit count: 9

cargo fmt