Struct zerovec::ule::OptionVarULE
source · [−]Expand description
A type allowing one to represent Option<U>
for VarULE
U
types.
use zerovec::ule::OptionVarULE;
use zerovec::VarZeroVec;
let mut zv: VarZeroVec<OptionVarULE<str>> = VarZeroVec::new();
zv.make_mut().push(&None::<&str>);
zv.make_mut().push(&Some("hello"));
zv.make_mut().push(&Some("world"));
zv.make_mut().push(&None::<&str>);
assert_eq!(zv.get(0).unwrap().as_ref(), None);
assert_eq!(zv.get(1).unwrap().as_ref(), Some("hello"));
Implementations
Trait Implementations
sourceimpl<T, U> EncodeAsVarULE<OptionVarULE<U>> for Option<T> where
T: EncodeAsVarULE<U>,
U: VarULE + ?Sized,
impl<T, U> EncodeAsVarULE<OptionVarULE<U>> for Option<T> where
T: EncodeAsVarULE<U>,
U: VarULE + ?Sized,
sourcefn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R
fn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R
Calls cb
with a piecewise list of byte slices that when concatenated
produce the memory pattern of the corresponding instance of T
. Read more
sourcefn encode_var_ule_len(&self) -> usize
fn encode_var_ule_len(&self) -> usize
Return the length, in bytes, of the corresponding VarULE
type
sourcefn encode_var_ule_write(&self, dst: &mut [u8])
fn encode_var_ule_write(&self, dst: &mut [u8])
Write the corresponding VarULE
type to the dst
buffer. dst
should
be the size of Self::encode_var_ule_len()
Read more
sourceimpl<U: VarULE + ?Sized + Ord> Ord for OptionVarULE<U>
impl<U: VarULE + ?Sized + Ord> Ord for OptionVarULE<U>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<U: VarULE + ?Sized + PartialEq> PartialEq<OptionVarULE<U>> for OptionVarULE<U>
impl<U: VarULE + ?Sized + PartialEq> PartialEq<OptionVarULE<U>> for OptionVarULE<U>
sourceimpl<U: VarULE + ?Sized + PartialOrd> PartialOrd<OptionVarULE<U>> for OptionVarULE<U>
impl<U: VarULE + ?Sized + PartialOrd> PartialOrd<OptionVarULE<U>> for OptionVarULE<U>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<U: VarULE + ?Sized> VarULE for OptionVarULE<U>
impl<U: VarULE + ?Sized> VarULE for OptionVarULE<U>
sourcefn validate_byte_slice(slice: &[u8]) -> Result<(), ZeroVecError>
fn validate_byte_slice(slice: &[u8]) -> Result<(), ZeroVecError>
Validates a byte slice, &[u8]
. Read more
sourceunsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
unsafe fn from_byte_slice_unchecked(bytes: &[u8]) -> &Self
Takes a byte slice, &[u8]
, and return it as &Self
with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_byte_slice()
with
success. Read more
sourcefn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
fn parse_byte_slice(bytes: &[u8]) -> Result<&Self, ZeroVecError>
Parses a byte slice, &[u8]
, and return it as &Self
with the same lifetime. Read more
sourcefn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
fn as_byte_slice(&self) -> &[u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
Given &Self
, returns a &[u8]
with the same lifetime. Read more
sourcefn to_boxed(&self) -> Box<Self>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
fn to_boxed(&self) -> Box<Self>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Allocate on the heap as a Box<T>
sourceimpl<'a, T> ZeroMapKV<'a> for OptionVarULE<T> where
T: VarULE + ?Sized,
impl<'a, T> ZeroMapKV<'a> for OptionVarULE<T> where
T: VarULE + ?Sized,
type Container = VarZeroVec<'a, OptionVarULE<T>, Index16>
type Container = VarZeroVec<'a, OptionVarULE<T>, Index16>
The container that can be used with this type: ZeroVec
or VarZeroVec
.
type Slice = VarZeroSlice<OptionVarULE<T>, Index16>
type GetType = OptionVarULE<T>
type GetType = OptionVarULE<T>
The type produced by Container::get()
Read more
type OwnedType = Box<OptionVarULE<T>, Global>
type OwnedType = Box<OptionVarULE<T>, Global>
The type produced by Container::replace()
and Container::remove()
,
also used during deserialization. If Self
is human readable serialized,
deserializing to Self::OwnedType
should produce the same value once
passed through Self::owned_as_self()
Read more