asserter 0.1.0

New assertion library for rust
Documentation
  • Coverage
  • 100%
    1 out of 1 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.03 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kdy1

asserter

Build Status

A new testing utility for rust

Features

  • Works on stable

  • unwrap!

You can easily unwrap nested value easily.

use asserter::*;

enum Complex {
    Normal(String),
    Boxed(Box<Complex>),
}

#[asserter]
fn main() {
    let foo = Complex::Boxed(Box::new(Complex::Normal(String::from("foo"))));

    unwrap!(foo as Complex::Boxed(unbox!(Complex::Normal(s))));
    assert_eq!(s, "foo");   
}

Also, you can use box patterns in unwrap!.

use asserter::*;

enum Complex {
    Normal(String),
    Boxed(Box<Complex>),
}

#[asserter]
fn main() {
    let foo = Complex::Boxed(Box::new(Complex::Normal(String::from("foo"))));

    unwrap!(foo as Complex::Boxed(box Complex::Normal(s)));
    assert_eq!(s, "foo");   
}
  • rustfmt-friendly

There are some syntax sugars to allow using rustfmt with it.

Usage

Cargo.tml:

[dependencies]
asserter = "0.1"
#[asserter]
fn main() {
    let foo = Complex::Boxed(Box::new(Complex::Normal(String::from("foo"))));

    unwrap!(foo as Complex::Boxed(box Complex::Normal(s)));
    assert_eq!(s, "foo");   
}