pub struct ConstOption<T, const IS_SOME: bool>(/* private fields */);Expand description
An Option type that is known at compile-time to have or not some value. This is usefull for
writing data structures that use const generics and would like to hold or not a value of some
type based on a compile-time rule.
§Example
ⓘ
struct Person<const HAS_DOG: bool> {
name: String,
age: usize,
dog_name: ConstOption<String, HAS_DOG>,
}Implementations§
Source§impl<T> ConstOption<T, false>
impl<T> ConstOption<T, false>
Source§impl<T> ConstOption<T, true>
impl<T> ConstOption<T, true>
pub fn new(val: T) -> Self
pub fn into_inner(self) -> T
Trait Implementations§
Source§impl<T> AsMut<T> for ConstOption<T, true>
impl<T> AsMut<T> for ConstOption<T, true>
Source§impl<T> AsRef<T> for ConstOption<T, true>
impl<T> AsRef<T> for ConstOption<T, true>
Source§impl<T> Deref for ConstOption<T, true>
impl<T> Deref for ConstOption<T, true>
Source§impl<T> DerefMut for ConstOption<T, true>
impl<T> DerefMut for ConstOption<T, true>
Auto Trait Implementations§
impl<T, const IS_SOME: bool> Freeze for ConstOption<T, IS_SOME>where
T: Freeze,
impl<T, const IS_SOME: bool> RefUnwindSafe for ConstOption<T, IS_SOME>where
T: RefUnwindSafe,
impl<T, const IS_SOME: bool> Send for ConstOption<T, IS_SOME>where
T: Send,
impl<T, const IS_SOME: bool> Sync for ConstOption<T, IS_SOME>where
T: Sync,
impl<T, const IS_SOME: bool> Unpin for ConstOption<T, IS_SOME>where
T: Unpin,
impl<T, const IS_SOME: bool> UnwindSafe for ConstOption<T, IS_SOME>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