no-std assert_bound

Simple create that helps in asserting type bounds

2 releases

✓ Uses Rust 2018 edition

new 0.1.1 Nov 29, 2019
0.1.0 Nov 29, 2019

#220 in #no-std

MIT license

60 lines


Simple rust lib for type assertions.


use assert_bound::assert_bound;

// assert that `()` implements Debug + Ord + PartialEq<()>
assert_bound!(() => std::fmt::Debug + Ord + PartialEq<()>);

// f32/f64 doesn't implement `Eq`, so rustc will 
// fail to compile next line if it you uncomment it
// assert_bound!(0.1 => Eq);


When working with iterators/futures or other hign-generic types sometimes it's useful to assert that type of some expression implements some traits or even cast smt to impl Trait.

This crate provides macros for both goals — assert_bound and as_opaque.

No runtime deps