[−][src]Struct scones_examples::OverridableBuilt
An example showing how to use overrides in builders.
Overrides are sugar for accomplishing the job the OptionalBuilt
example does with less
verbosity. This example is defined as follows:
#[make_builder(pub OverridableBuilder(defaults_to_zero?))] pub struct OverridableBuilt { #[value(0)] pub defaults_to_zero: i32, }
The resulting builder will allow building this struct without specifying a value for
defaults_to_zero
, in which case zero will be used. At the same time, it allows a user of
the builder to override that default, without you having to explicitly add a custom parameter,
give it an Option<>
type, and unwrap_or
it in the #[value()]
annotation.
Fields
defaults_to_zero: i32
Auto Trait Implementations
impl RefUnwindSafe for OverridableBuilt
impl Send for OverridableBuilt
impl Sync for OverridableBuilt
impl Unpin for OverridableBuilt
impl UnwindSafe for OverridableBuilt
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,