#macro #assert #static #impl

assert-impl

Macro for static assert types implement a trait or not

4 releases

Uses old Rust 2015

0.1.3 Aug 10, 2018
0.1.2 Aug 10, 2018
0.1.1 Aug 10, 2018
0.1.0 Aug 9, 2018

#17 in #impl

Download history 2509/week @ 2023-10-15 1781/week @ 2023-10-22 1379/week @ 2023-10-29 3661/week @ 2023-11-05 4177/week @ 2023-11-12 6590/week @ 2023-11-19 5359/week @ 2023-11-26 4849/week @ 2023-12-03 3496/week @ 2023-12-10 1142/week @ 2023-12-17 1135/week @ 2023-12-24 1990/week @ 2023-12-31 2447/week @ 2024-01-07 1776/week @ 2024-01-14 1371/week @ 2024-01-21 1397/week @ 2024-01-28

7,677 downloads per month
Used in 22 crates (15 directly)

MIT license

5KB

Macro for static assert that types implement a trait or not.

Note: this macro can only be used inside function body due to restriction of Rust.

Example

Assuming you have the following definitions:

struct C;
struct Java;
struct JavaScript;
struct Python;
struct Rust;

trait StaticTyping {}
impl StaticTyping for C {}
impl StaticTyping for Java {}
impl StaticTyping for Rust {}

This should build:

assert_impl!(StaticTyping: C, Java, Rust);
assert_impl!(StaticTyping: C, Java, Rust, );
assert_impl!(!StaticTyping: JavaScript, Python);
assert_impl!(!StaticTyping: JavaScript, Python, );

But this should fail to build:

assert_impl!(StaticTyping: JavaScript);
assert_impl!(!StaticTyping: Rust);

lib.rs:

Macro for static assert that types implement a trait or not.

Note: this macro can only be used inside function body due to restriction of Rust.

Example

Assuming you have the following definitions:

struct C;
struct Java;
struct JavaScript;
struct Python;
struct Rust;

trait StaticTyping {}
impl StaticTyping for C {}
impl StaticTyping for Java {}
impl StaticTyping for Rust {}

This should build:

assert_impl!(StaticTyping: C, Java, Rust);
assert_impl!(StaticTyping: C, Java, Rust, );
assert_impl!(!StaticTyping: JavaScript, Python);
assert_impl!(!StaticTyping: JavaScript, Python, );

But these should fail to build:

assert_impl!(StaticTyping: JavaScript);
assert_impl!(!StaticTyping: Rust);

No runtime deps