Expand description
Derive macro complementing if_empty
This crate provides a derive macro implementing the if_empty
function if the type has a
is_empty
function.
§Examples
#[derive(IfEmpty)]
struct Example {
value: String,
}
impl Example {
fn is_empty(&self) -> bool {
self.value.is_empty()
}
}
let example = Example {
value: String::new(),
};
assert!(example.value.is_empty());
assert_eq!(example.if_empty(Example {value: "a default".to_string()}).value, "a default");
Derive Macros§
- IfEmpty
- Implement
if_empty
on types withis_empty
functions