#macro-derive #serde #derive #macro

is_empty

Easily check if the struct is empty

3 releases (breaking)

0.3.0 Nov 9, 2024
0.2.0 Jan 19, 2023
0.1.0 Jan 19, 2023

#335 in Rust patterns

Download history 708/week @ 2024-08-17 913/week @ 2024-08-24 576/week @ 2024-08-31 1119/week @ 2024-09-07 956/week @ 2024-09-14 958/week @ 2024-09-21 876/week @ 2024-09-28 897/week @ 2024-10-05 1242/week @ 2024-10-12 1034/week @ 2024-10-19 862/week @ 2024-10-26 1205/week @ 2024-11-02 1052/week @ 2024-11-09 1318/week @ 2024-11-16 917/week @ 2024-11-23 943/week @ 2024-11-30

4,421 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

11KB
80 lines

is_empty

CI status Docs Badge

Easily check if the struct is empty.

Usage

use is_empty::IsEmpty;

#[derive(IsEmpty)]
struct Foo {
    a: Option<String>,
    b: Option<String>,
}

let foo = Foo {
    a: Some("a".to_string()),
    b: None,
};
assert!(!foo.is_empty());

let bar = Foo {
   a: None,
   b: None,
};
assert!(bar.is_empty());

Acknowledgements

This crate was made possible by the excellent blog series on derive macros by Jonas Platte.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5MB
~37K SLoC