none-guard/examples/example.rs

32 lines
483 B
Rust
Raw Normal View History

2023-11-23 20:45:47 +00:00
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());
}