pub enum PropValue<T> {
Value(T),
Default(fn() -> T),
Required,
}
Expand description
Represents a property that can be required or optional with default value
Variants§
Value(T)
Value is present
Default(fn() -> T)
Value is not present, but there is a default
Required
Value is required but not present
Implementations§
Source§impl<T: Clone> PropValue<T>
impl<T: Clone> PropValue<T>
Sourcepub fn get(&self) -> Result<T, PropValidationError>
pub fn get(&self) -> Result<T, PropValidationError>
Get the value, returning default if needed
Sourcepub fn new_default(default_fn: fn() -> T) -> Self
pub fn new_default(default_fn: fn() -> T) -> Self
Create a new optional value with default
Sourcepub fn new_required() -> Self
pub fn new_required() -> Self
Create a new required value
Auto Trait Implementations§
impl<T> Freeze for PropValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for PropValue<T>where
T: RefUnwindSafe,
impl<T> Send for PropValue<T>where
T: Send,
impl<T> Sync for PropValue<T>where
T: Sync,
impl<T> Unpin for PropValue<T>where
T: Unpin,
impl<T> UnwindSafe for PropValue<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more