none-guard/examples/example.rs
2023-11-23 21:45:47 +01:00

31 lines
483 B
Rust

use none_guard::NoneGuard;
#[derive(NoneGuard)]
struct Test {
x: Option<i32>,
y: Option<String>,
z: Option<f32>,
}
fn main() {
let x = Test {
x: Some(1),
y: None,
z: None,
};
dbg!(x.is_all_none());
let y = Test {
x: None,
y: Some("dd".to_string()),
z: Some(2.0),
};
dbg!(y.is_all_none());
let z = Test {
x: None,
y: None,
z: None,
};
dbg!(z.is_all_none());
}