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§

source

type T

Entry type

Required Methods§

source

fn access(&mut self) -> &mut Vec<Self::T>

Get access to the Vec, defaulting it

source

fn access_opt(&self) -> &Option<Vec<Self::T>>

Get access to the Option<Vec>

source

fn access_opt_mut(&mut self) -> &mut Option<Vec<Self::T>>

Get mutable access to the Option<Vec>

Implementations on Foreign Types§

source§

impl<T> DirectDefaultEmptyListBuilderAccessors for Option<Vec<T>>

§

type T = T

source§

fn access(&mut self) -> &mut Vec<T>

source§

fn access_opt(&self) -> &Option<Vec<T>>

source§

fn access_opt_mut(&mut self) -> &mut Option<Vec<T>>

Implementors§