pub trait DirectDefaultEmptyListBuilderAccessors {
type T;
// Required methods
fn access(&mut self) -> &mut Vec<Self::T>;
fn access_opt(&self) -> &Option<Vec<Self::T>>;
fn access_opt_mut(&mut self) -> &mut Option<Vec<Self::T>>;
}
Expand description
Extension trait, an alternative to define_list_builder_helper
Useful for a handwritten Builder
which wants to contain a list,
which is an Option<Vec<ItemBuilder>>
.
Example
use tor_config::define_list_builder_accessors;
#[derive(Default)]
struct WombatBuilder {
leg_lengths: Option<Vec<u32>>,
}
define_list_builder_accessors! {
struct WombatBuilder {
leg_lengths: [u32],
}
}
let mut wb = WombatBuilder::default();
wb.leg_lengths().push(42);
assert_eq!(wb.leg_lengths, Some(vec![42]));
It is not necessary to use
this trait anywhere in your code;
the macro define_list_builder_accessors
arranges to have it in scope where it needs it.
Required Associated Types§
Required Methods§
sourcefn access_opt(&self) -> &Option<Vec<Self::T>>
fn access_opt(&self) -> &Option<Vec<Self::T>>
Get access to the Option<Vec>
sourcefn access_opt_mut(&mut self) -> &mut Option<Vec<Self::T>>
fn access_opt_mut(&mut self) -> &mut Option<Vec<Self::T>>
Get mutable access to the Option<Vec>