Skip to content

reem/rust-enforce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enforce

Fluid Assertions in Rust

Example

Uses stainless for testing syntax

describe! vec {
    describe! push {
        before_each {
            let mut v = vec![1u, 2, 3];
        }

        it "should increase the length by 1" {
            let old = v.len();
            v.push(4u);
            // Fluid chain with informative error messages.
            (enforce!(old + 1)).is().equal(v.len());
        }

        it "should add another value to the end of the vec" {
            v.push(4u);
            // Has `some`, `none`, `ok`, and `err` methods for checking Option
            // and Result APIs.
            (enforce!(*v.get_mut(3))).is().some();
        }
    }
}

Failed Assertion

Enforce Error file.rs:17 - map.find("no such key") is None

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages