Enum aws_smithy_types::tristate::TriState
source · [−]pub enum TriState<T> {
Unset,
Disabled,
Set(T),
}
Expand description
Utility for tracking set vs. unset vs explicitly disabled
If someone explicitly disables something, we don’t need to warn them that it may be missing. This
enum impls From
/Into
Option<T>
for ease of use.
Variants
Unset
This variant represents something that was unset by default
Disabled
This variant represents something that was intentionally unset
Set(T)
This variant represents something that was intentionally set
Implementations
sourceimpl<T> TriState<T>
impl<T> TriState<T>
sourcepub fn or(self, other: TriState<T>) -> TriState<T>
pub fn or(self, other: TriState<T>) -> TriState<T>
Returns the tristate if it contains a set value or is disabled, otherwise returns other
Examples
let disabled_timeout: TriState<Duration> = TriState::Disabled;
let timeout: TriState<Duration> = TriState::Set(Duration::from_secs(1));
assert_eq!(timeout.or(disabled_timeout), TriState::Set(Duration::from_secs(1)));
let disabled_timeout: TriState<Duration> = TriState::Disabled;
let timeout: TriState<Duration> = TriState::Set(Duration::from_secs(2));
assert_eq!(disabled_timeout.or(timeout), TriState::Disabled);
let unset_timeout: TriState<Duration> = TriState::Unset;
let timeout: TriState<Duration> = TriState::Set(Duration::from_secs(3));
assert_eq!(unset_timeout.or(timeout), TriState::Set(Duration::from_secs(3)));
Trait Implementations
impl<T: Eq> Eq for TriState<T>
impl<T> StructuralEq for TriState<T>
impl<T> StructuralPartialEq for TriState<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for TriState<T> where
T: RefUnwindSafe,
impl<T> Send for TriState<T> where
T: Send,
impl<T> Sync for TriState<T> where
T: Sync,
impl<T> Unpin for TriState<T> where
T: Unpin,
impl<T> UnwindSafe for TriState<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more