Crate must [] [src]

Usage

Add must to your Cargo.toml file.

[dev-dependencies]
must = "0.1.*"

And add

#[cfg_attr(test, macro_use)]
#[cfg(test)]
extern crate must;

to your root module.

Then add

use must::prelude::*;

your test module.

Examples

#[macro_use] extern crate must;
use must::prelude::*;
// fail!() is optional, and if not called, it will panic on drop.
// but as it's value is not used, it will be dropped right after one assertion chain.


Some(5u8).must_be_some_and(|val| {
    // fail! macro supports formatting, but value is printed without manually printing it.
    val.must_be(5).or(fail!("your msg {}", "and args"));
}).or(fail!());
// fail!() macro captures location, so you can know source of panic without backtrace.


fn double(x: usize) -> usize {
    x * 2
}

10.must_be_in_range(10..);
10.must_not_be_in_range(..10);
double(10).must_be_in_range(..);
double(10).must_not_be_in_range(..20);

Modules

error_renderer
marker

Marker trait for types.

matcher
prelude
result

Macros

fail

fail!() - Just capture source location.