pub struct OptionExpand<T: CubeType> { /* private fields */ }Implementations§
Source§impl<T: CubeType> OptionExpand<T>
impl<T: CubeType> OptionExpand<T>
Sourcepub fn __expand_is_none_method(
&self,
scope: &Scope,
) -> <bool as CubeType>::ExpandType
pub fn __expand_is_none_method( &self, scope: &Scope, ) -> <bool as CubeType>::ExpandType
Sourcepub fn __expand_unwrap_method(
self,
scope: &Scope,
) -> <T as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
pub fn __expand_unwrap_method(
self,
scope: &Scope,
) -> <T as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
Returns the contained Some value, consuming the self value.
Because this function may panic, its use is generally discouraged. Panics are meant for unrecoverable errors, and may abort the entire program.
Instead, prefer to use pattern matching and handle the None
case explicitly, or call unwrap_or, unwrap_or_else, or
unwrap_or_default. In functions returning Option, you can use
the ? (try) operator.
§Panics
Panics if the self value equals None.
§Examples
let x = Some("air");
assert_eq!(x.unwrap(), "air");let x: Option<&str> = None;
assert_eq!(x.unwrap(), "air"); // failsSourcepub fn __expand_unwrap_or_method(
self,
scope: &Scope,
default: <T as CubeType>::ExpandType,
) -> <T as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
pub fn __expand_unwrap_or_method(
self,
scope: &Scope,
default: <T as CubeType>::ExpandType,
) -> <T as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
Returns the contained Some value or a provided default.
Arguments passed to unwrap_or are eagerly evaluated; if you are passing
the result of a function call, it is recommended to use unwrap_or_else,
which is lazily evaluated.
§Examples
assert_eq!(Some("car").unwrap_or("bike"), "car");
assert_eq!(None.unwrap_or("bike"), "bike");Sourcepub fn __expand_unwrap_or_default_method(
self,
scope: &Scope,
) -> <T as CubeType>::ExpandType
pub fn __expand_unwrap_or_default_method( self, scope: &Scope, ) -> <T as CubeType>::ExpandType
Returns the contained Some value or a default.
Consumes the self argument then, if Some, returns the contained
value, otherwise if None, returns the default value for that
type.
§Examples
let x: Option<u32> = None;
let y: Option<u32> = Some(12);
assert_eq!(x.unwrap_or_default(), 0);
assert_eq!(y.unwrap_or_default(), 12);Sourcepub fn __expand_and_method<U>(
self,
scope: &Scope,
optb: <Option<U> as CubeType>::ExpandType,
) -> <Option<U> as CubeType>::ExpandType
pub fn __expand_and_method<U>( self, scope: &Scope, optb: <Option<U> as CubeType>::ExpandType, ) -> <Option<U> as CubeType>::ExpandType
Returns None if the option is None, otherwise returns optb.
Arguments passed to and are eagerly evaluated; if you are passing the
result of a function call, it is recommended to use and_then, which is
lazily evaluated.
§Examples
let x = Some(2);
let y: Option<&str> = None;
assert_eq!(x.and(y), None);
let x: Option<u32> = None;
let y = Some("foo");
assert_eq!(x.and(y), None);
let x = Some(2);
let y = Some("foo");
assert_eq!(x.and(y), Some("foo"));
let x: Option<u32> = None;
let y: Option<&str> = None;
assert_eq!(x.and(y), None);Sourcepub fn __expand_or_method(
self,
scope: &Scope,
optb: <Option<T> as CubeType>::ExpandType,
) -> <Option<T> as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
pub fn __expand_or_method(
self,
scope: &Scope,
optb: <Option<T> as CubeType>::ExpandType,
) -> <Option<T> as CubeType>::ExpandTypewhere
T::ExpandType: RuntimeAssign,
Returns the option if it contains a value, otherwise returns optb.
Arguments passed to or are eagerly evaluated; if you are passing the
result of a function call, it is recommended to use or_else, which is
lazily evaluated.
§Examples
let x = Some(2);
let y = None;
assert_eq!(x.or(y), Some(2));
let x = None;
let y = Some(100);
assert_eq!(x.or(y), Some(100));
let x = Some(2);
let y = Some(100);
assert_eq!(x.or(y), Some(2));
let x: Option<u32> = None;
let y = None;
assert_eq!(x.or(y), None);Sourcepub fn __expand_xor_method(
self,
scope: &Scope,
optb: <Option<T> as CubeType>::ExpandType,
) -> <Option<T> as CubeType>::ExpandType
pub fn __expand_xor_method( self, scope: &Scope, optb: <Option<T> as CubeType>::ExpandType, ) -> <Option<T> as CubeType>::ExpandType
Returns Some if exactly one of self, optb is Some, otherwise returns None.
§Examples
let x = Some(2);
let y: Option<u32> = None;
assert_eq!(x.xor(y), Some(2));
let x: Option<u32> = None;
let y = Some(2);
assert_eq!(x.xor(y), Some(2));
let x = Some(2);
let y = Some(2);
assert_eq!(x.xor(y), None);
let x: Option<u32> = None;
let y: Option<u32> = None;
assert_eq!(x.xor(y), None);Sourcepub fn __expand_zip_method<U>(
self,
scope: &Scope,
other: <Option<U> as CubeType>::ExpandType,
) -> <Option<(T, U)> as CubeType>::ExpandTypewhere
U: CubeType,
(T, U): Default + CubeType + IntoRuntime,
(T::ExpandType, U::ExpandType): Into<<(T, U) as CubeType>::ExpandType>,
OptionExpand<(T, U)>: RuntimeAssign + IntoExpand<Expand = OptionExpand<(T, U)>>,
pub fn __expand_zip_method<U>(
self,
scope: &Scope,
other: <Option<U> as CubeType>::ExpandType,
) -> <Option<(T, U)> as CubeType>::ExpandTypewhere
U: CubeType,
(T, U): Default + CubeType + IntoRuntime,
(T::ExpandType, U::ExpandType): Into<<(T, U) as CubeType>::ExpandType>,
OptionExpand<(T, U)>: RuntimeAssign + IntoExpand<Expand = OptionExpand<(T, U)>>,
Zips self with another Option.
If self is Some(s) and other is Some(o), this method returns Some((s, o)).
Otherwise, None is returned.
§Examples
let x = Some(1);
let y = Some("hi");
let z = None::<u8>;
assert_eq!(x.zip(y), Some((1, "hi")));
assert_eq!(x.zip(z), None);Source§impl<T: CubeType<ExpandType: RuntimeAssign> + IntoRuntime + Default, U: CubeType<ExpandType: RuntimeAssign> + IntoRuntime + Default> OptionExpand<(T, U)>
impl<T: CubeType<ExpandType: RuntimeAssign> + IntoRuntime + Default, U: CubeType<ExpandType: RuntimeAssign> + IntoRuntime + Default> OptionExpand<(T, U)>
Sourcepub fn __expand_unzip_method(
self,
scope: &Scope,
) -> (<Option<T> as CubeType>::ExpandType, <Option<U> as CubeType>::ExpandType)
pub fn __expand_unzip_method( self, scope: &Scope, ) -> (<Option<T> as CubeType>::ExpandType, <Option<U> as CubeType>::ExpandType)
Unzips an option containing a tuple of two options.
If self is Some((a, b)) this method returns (Some(a), Some(b)).
Otherwise, (None, None) is returned.
§Examples
let x = Some((1, "hi"));
let y = None::<(u8, u32)>;
assert_eq!(x.unzip(), (Some(1), Some("hi")));
assert_eq!(y.unzip(), (None, None));Trait Implementations§
Source§impl<T: CubeType> AsMutExpand for OptionExpand<T>
impl<T: CubeType> AsMutExpand for OptionExpand<T>
fn __expand_ref_mut_method(&mut self, _: &Scope) -> &mut Self
fn __expand_as_mut_method(&mut self, scope: &Scope) -> &mut T
Source§impl<T: CubeType> AsRefExpand for OptionExpand<T>
impl<T: CubeType> AsRefExpand for OptionExpand<T>
fn __expand_ref_method(&self, _: &Scope) -> &Self
fn __expand_as_ref_method(&self, scope: &Scope) -> &T
Source§impl<T: CubeType> Assign for OptionExpand<T>
impl<T: CubeType> Assign for OptionExpand<T>
Source§fn __expand_assign_method(&mut self, scope: &Scope, value: Self)
fn __expand_assign_method(&mut self, scope: &Scope, value: Self)
value to self in scope.Source§impl<T: CubeType> CubeDebug for OptionExpand<T>
impl<T: CubeType> CubeDebug for OptionExpand<T>
Source§fn set_debug_name(&self, scope: &Scope, name: &'static str)
fn set_debug_name(&self, scope: &Scope, name: &'static str)
Source§impl<T: CubeType> CubeEnum for OptionExpand<T>
impl<T: CubeType> CubeEnum for OptionExpand<T>
type RuntimeValue = <T as CubeType>::ExpandType
fn discriminant(&self) -> NativeExpand<i32>
Source§fn runtime_value(self) -> Self::RuntimeValue
fn runtime_value(self) -> Self::RuntimeValue
fn discriminant_of(variant_name: &'static str) -> i32
fn discriminant_of_value(&self, variant_name: &'static str) -> i32
Source§impl<T: CubeType> ExpandTypeClone for OptionExpand<T>
impl<T: CubeType> ExpandTypeClone for OptionExpand<T>
Source§fn clone_unchecked(&self) -> Self
fn clone_unchecked(&self) -> Self
Clone semantics and should only be used for the
conceptual expand values, never real data. Using two values in the same branch is undefined
behaviour.Source§impl<T: CubeType> IntoExpand for OptionExpand<T>
impl<T: CubeType> IntoExpand for OptionExpand<T>
type Expand = OptionExpand<T>
fn into_expand(self, _: &Scope) -> Self
Source§impl<T: CubeType> IntoMut for OptionExpand<T>
impl<T: CubeType> IntoMut for OptionExpand<T>
Source§impl<T: CubeType> RuntimeAssign for OptionExpand<T>
impl<T: CubeType> RuntimeAssign for OptionExpand<T>
Auto Trait Implementations§
impl<T> Freeze for OptionExpand<T>
impl<T> RefUnwindSafe for OptionExpand<T>
impl<T> Send for OptionExpand<T>
impl<T> Sync for OptionExpand<T>
impl<T> Unpin for OptionExpand<T>
impl<T> UnsafeUnpin for OptionExpand<T>
impl<T> UnwindSafe for OptionExpand<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more