pub trait Filler<F> {
// Required methods
fn apply(&mut self, filler: F);
fn new_empty_filler() -> F;
// Provided method
fn apply_with_log<L: FnMut(&str)>(&mut self, filler: F, _log: L) { ... }
}Required Methods§
Sourcefn new_empty_filler() -> F
fn new_empty_filler() -> F
Get an empty filler instance
Provided Methods§
Sourcefn apply_with_log<L: FnMut(&str)>(&mut self, filler: F, _log: L)
fn apply_with_log<L: FnMut(&str)>(&mut self, filler: F, _log: L)
Apply a filler, calling log with each field name that is actually filled.
The default implementation ignores log and delegates to apply.
The derive macro generates an override that calls log once per field that is
actually filled (i.e. the field was empty and the filler supplied a value).
#[derive(Default, Filler)]
struct Item {
value: Option<usize>,
}
let mut item = Item::default();
let filler = ItemFiller { value: Some(42) };
let mut filled_fields = Vec::new();
item.apply_with_log(filler, |field| filled_fields.push(field.to_string()));
assert_eq!(filled_fields, vec!["value"]);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".