cleanass 0.0.1

Enhances assert, assert_eq and assert_ne with cleanup statement which runs on failure
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use cleanass::assert_eq;

pub fn main() {
    // If assert succeeds nothing is printed since cleanup function does not run
    {
        let a = 1;
        let b = 1;
        assert_eq!(a, b, eprintln!("Cleanup: {} == {} succeeded", a, b));
    }
    // If assert fails the cleanup function runs and prints the message
    {
        let a = 1;
        let b = 2;
        assert_eq!(a, b, eprintln!("Cleanup: {} == {} failed", a, b));
    }
}