Struct abi_stable::nonexhaustive_enum::NonExhaustive
source · #[repr(C)]pub struct NonExhaustive<E, S, I> { /* private fields */ }
Expand description
A generic type for all ffi-safe non-exhaustive enums.
This type allows adding variants to enums it wraps in ABI compatible versions of a library.
Generic parameters
E
This is the enum that this was constructed from, and can be unwrapped back into if it’s one of the valid variants in this context.
S
The storage type,used to store the enum opaquely.
This has to be at least the size and alignment of the wrapped enum.
This is necessary because:
-
The compiler assumes that an enum cannot be a variant outside the ones it sees.
-
To give some flexibility to grow the enum in semver compatible versions of a library.
I
The interface of the enum(it implements InterfaceType
),
determining which traits are required when constructing NonExhaustive<>
and which are available afterwards.
Examples
Error type
Say that we define an error type for a library.
Version 1.0.
use abi_stable::{
nonexhaustive_enum::{NonExhaustive, NonExhaustiveFor},
sabi_trait,
std_types::RString,
StableAbi,
};
#[repr(u8)]
#[derive(StableAbi, Debug, Clone, PartialEq)]
#[sabi(kind(WithNonExhaustive(
size = [usize;8],
traits(Debug, Clone, PartialEq),
)))]
#[non_exhaustive]
pub enum Error {
CouldNotFindItem {
name: RString,
},
OutOfStock {
id: usize,
name: RString,
},
}
fn returns_could_not_find_item(name: RString) -> NonExhaustiveFor<Error> {
let e = Error::CouldNotFindItem { name };
NonExhaustive::new(e)
}
fn returns_out_of_stock(id: usize, name: RString) -> NonExhaustiveFor<Error> {
let e = Error::OutOfStock { id, name };
NonExhaustive::new(e)
}
Then in 1.1 we add another error variant,returned only by new library functions.
use abi_stable::{
nonexhaustive_enum::{NonExhaustive, NonExhaustiveFor},
sabi_trait,
std_types::RString,
StableAbi,
};
#[repr(u8)]
#[derive(StableAbi, Debug, Clone, PartialEq)]
#[sabi(kind(WithNonExhaustive(
size = [usize;8],
traits(Debug, Clone, PartialEq),
)))]
#[non_exhaustive]
pub enum Error {
CouldNotFindItem {
name: RString,
},
OutOfStock {
id: usize,
name: RString,
},
InvalidItemId {
id: usize,
},
}
fn returns_invalid_item_id() -> NonExhaustiveFor<Error> {
NonExhaustive::new(Error::InvalidItemId { id: 100 })
}
If a library user attempted to unwrap Error::InvalidItemId
(using NonExhaustive::as_enum/as_enum_mut/into_enum)
with the 1.0 version of Error
they would get an Err(..)
back.
Static enums
This example demonstrates putting a nonexhaustive enum in a static.
use abi_stable::{
nonexhaustive_enum::{NonExhaustive, NonExhaustiveFor},
std_types::RString,
rstr, StableAbi,
};
static AA: NonExhaustiveFor<Foo> = NonExhaustive::new(Foo::A);
static BB: NonExhaustiveFor<Foo> = NonExhaustive::new(Foo::B(2));
let cc = NonExhaustive::new(Foo::C {name: "hello".into()});
assert_eq!(AA, Foo::A);
assert_eq!(BB, Foo::B(2));
assert_eq!(cc, Foo::C {name: RString::from("hello")});
#[repr(u8)]
#[derive(StableAbi, Debug, PartialEq, Eq)]
#[sabi(kind(WithNonExhaustive(
size = 64,
traits(Debug, PartialEq, Eq)
)))]
pub enum Foo {
A,
B(i8),
C { name: RString },
}
Implementations§
source§impl<E, S, I> NonExhaustive<E, S, I>
impl<E, S, I> NonExhaustive<E, S, I>
sourcepub const fn new(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S, DefaultInterface = I>,
pub const fn new(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S, DefaultInterface = I>,
Constructs a NonExhaustive<>
from value
using its default interface and storage.
Panic
This panics if the storage has an alignment or size smaller than that of E
.
sourcepub const fn with_interface(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S>,
pub const fn with_interface(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultStorage = S>,
Constructs a NonExhaustive<>
from value
using its default storage
and a custom interface.
Panic
This panics if the storage has an alignment or size smaller than that of E
.
sourcepub const fn with_storage(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultInterface = I>,
pub const fn with_storage(value: E) -> Selfwhere
E: GetVTable<S, I> + GetEnumInfo<DefaultInterface = I>,
Constructs a NonExhaustive<>
from value
using its default interface
and a custom storage.
Panic
This panics if the storage has an alignment or size smaller than that of E
.
sourcepub const fn with_storage_and_interface(value: E) -> Selfwhere
E: GetVTable<S, I>,
pub const fn with_storage_and_interface(value: E) -> Selfwhere
E: GetVTable<S, I>,
Constructs a NonExhaustive<>
from value
using both a custom interface and storage.
Panic
This panics if the storage has an alignment or size smaller than that of E
.
source§impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
sourcepub fn as_enum(&self) -> Result<&E, UnwrapEnumError<&Self>>
pub fn as_enum(&self) -> Result<&E, UnwrapEnumError<&Self>>
wraps a reference to this NonExhaustive<>
into a reference to the original enum.
Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_2::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().as_enum().ok(), Some(&Foo::A));
assert_eq!(new_b(10).as_enum().ok(), Some(&Foo::B(10)));
assert_eq!(new_b(77).as_enum().ok(), Some(&Foo::B(77)));
assert_eq!(new_c().as_enum().ok(), None);
sourcepub fn as_enum_mut(&mut self) -> Result<&mut E, UnwrapEnumError<&mut Self>>where
E: GetVTable<S, I>,
pub fn as_enum_mut(&mut self) -> Result<&mut E, UnwrapEnumError<&mut Self>>where
E: GetVTable<S, I>,
Unwraps a mutable reference to this NonExhaustive<>
into a
mutable reference to the original enum.
Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_1::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().as_enum_mut().ok(), Some(&mut Foo::A));
assert_eq!(new_b(10).as_enum_mut().ok(), None);
assert_eq!(new_b(77).as_enum_mut().ok(), None);
assert_eq!(new_c().as_enum_mut().ok(), None);
sourcepub fn into_enum(self) -> Result<E, UnwrapEnumError<Self>>
pub fn into_enum(self) -> Result<E, UnwrapEnumError<Self>>
Unwraps this NonExhaustive<>
into the original enum.
Errors
This returns an error if the wrapped enum is of a variant that is not valid in this context.
Example
This shows how some NonExhaustive<enum>
can be unwrapped, and others cannot.
That enum comes from a newer version of the library than this knows.
use abi_stable::nonexhaustive_enum::doc_enums::example_2::{
new_a, new_b, new_c, Foo,
};
assert_eq!(new_a().into_enum().ok(), Some(Foo::A));
assert_eq!(new_b(10).into_enum().ok(), Some(Foo::B(10)));
assert_eq!(new_b(77).into_enum().ok(), Some(Foo::B(77)));
assert_eq!(new_c().into_enum().ok(), None);
sourcepub fn is_valid_discriminant(&self) -> bool
pub fn is_valid_discriminant(&self) -> bool
Returns whether the discriminant of this enum is valid in this context.
The only way for it to be invalid is if the dynamic library is a newer version than this knows.
sourcepub const fn get_discriminant(&self) -> E::Discriminant
pub const fn get_discriminant(&self) -> E::Discriminant
Gets the value of the discriminant of the enum.
source§impl<E, S, I> NonExhaustive<E, S, I>
impl<E, S, I> NonExhaustive<E, S, I>
sourcepub const unsafe fn transmute_enum<F>(self) -> NonExhaustive<F, S, I>
pub const unsafe fn transmute_enum<F>(self) -> NonExhaustive<F, S, I>
sourcepub const unsafe fn transmute_enum_ref<F>(&self) -> &NonExhaustive<F, S, I>
pub const unsafe fn transmute_enum_ref<F>(&self) -> &NonExhaustive<F, S, I>
sourcepub unsafe fn transmute_enum_mut<F>(&mut self) -> &mut NonExhaustive<F, S, I>
pub unsafe fn transmute_enum_mut<F>(&mut self) -> &mut NonExhaustive<F, S, I>
sourcepub unsafe fn transmute_enum_ptr<P, F>(this: P) -> P::TransmutedPtr
pub unsafe fn transmute_enum_ptr<P, F>(this: P) -> P::TransmutedPtr
Transmute this pointer to a NonExhaustive<E,S,I>
into
a pointer (of the same kind) to a NonExhaustive<F,S,I>
,
changing the type of the enum it wraps.
Safety
This has the same safety requirements that
abi_stable::pointer_traits::TransmuteElement::transmute_element
has.
Panics
This panics if the storage has an alignment or size smaller than that of F
.
source§impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
impl<E, S, I> NonExhaustive<E, S, I>where
E: GetEnumInfo,
sourcepub fn serialize_into_proxy(&self) -> Result<I::Proxy, RBoxError>
pub fn serialize_into_proxy(&self) -> Result<I::Proxy, RBoxError>
It serializes a NonExhaustive<_>
into a proxy.
sourcepub fn deserialize_from_proxy<'borr>(proxy: I::Proxy) -> Result<Self, RBoxError>where
I: InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'borr, Self>,
I::Proxy: 'borr,
pub fn deserialize_from_proxy<'borr>(proxy: I::Proxy) -> Result<Self, RBoxError>where
I: InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'borr, Self>,
I::Proxy: 'borr,
Deserializes a NonExhaustive<_>
from a proxy.
Trait Implementations§
source§impl<E, S, I> Clone for NonExhaustive<E, S, I>
impl<E, S, I> Clone for NonExhaustive<E, S, I>
source§impl<E, S, I> Debug for NonExhaustive<E, S, I>
impl<E, S, I> Debug for NonExhaustive<E, S, I>
source§impl<'de, E, S, I> Deserialize<'de> for NonExhaustive<E, S, I>where
E: 'de + GetVTable<S, I>,
S: 'de,
I: 'de + InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'de, Self>,
<I as DeserializeEnum<'de, Self>>::Proxy: Deserialize<'de>,
impl<'de, E, S, I> Deserialize<'de> for NonExhaustive<E, S, I>where
E: 'de + GetVTable<S, I>,
S: 'de,
I: 'de + InterfaceType<Deserialize = Implemented<Deserialize>> + DeserializeEnum<'de, Self>,
<I as DeserializeEnum<'de, Self>>::Proxy: Deserialize<'de>,
First it Deserializes a string,then it deserializes into a
NonExhaustive<_>
,by using <I as DeserializeEnum>::deserialize_enum
.
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl<E, S, I> Display for NonExhaustive<E, S, I>
impl<E, S, I> Display for NonExhaustive<E, S, I>
source§impl<E, S, I> Drop for NonExhaustive<E, S, I>
impl<E, S, I> Drop for NonExhaustive<E, S, I>
source§impl<E, S, I> Error for NonExhaustive<E, S, I>where
I: InterfaceType<Debug = Implemented<Debug>, Display = Implemented<Display>, Error = Implemented<Error>>,
impl<E, S, I> Error for NonExhaustive<E, S, I>where
I: InterfaceType<Debug = Implemented<Debug>, Display = Implemented<Display>, Error = Implemented<Error>>,
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl<E, S, I> GetStaticEquivalent_ for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
impl<E, S, I> GetStaticEquivalent_ for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
§type StaticEquivalent = _static_NonExhaustive<<E as GetStaticEquivalent_>::StaticEquivalent, <S as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent>
type StaticEquivalent = _static_NonExhaustive<<E as GetStaticEquivalent_>::StaticEquivalent, <S as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent>
'static
equivalent of Self
source§impl<E, S, I> Hash for NonExhaustive<E, S, I>
impl<E, S, I> Hash for NonExhaustive<E, S, I>
§type Discriminant = <E as GetEnumInfo>::Discriminant
type Discriminant = <E as GetEnumInfo>::Discriminant
source§fn get_discriminant_(&self) -> E::Discriminant
fn get_discriminant_(&self) -> E::Discriminant
source§fn enum_info_(&self) -> &'static EnumInfo
fn enum_info_(&self) -> &'static EnumInfo
§type Discriminant = <E as GetEnumInfo>::Discriminant
type Discriminant = <E as GetEnumInfo>::Discriminant
source§fn get_discriminant_(&self) -> E::Discriminant
fn get_discriminant_(&self) -> E::Discriminant
source§fn enum_info_(&self) -> &'static EnumInfo
fn enum_info_(&self) -> &'static EnumInfo
§type Discriminant = <E as GetEnumInfo>::Discriminant
type Discriminant = <E as GetEnumInfo>::Discriminant
source§fn get_discriminant_(&self) -> E::Discriminant
fn get_discriminant_(&self) -> E::Discriminant
source§fn enum_info_(&self) -> &'static EnumInfo
fn enum_info_(&self) -> &'static EnumInfo
source§impl<E, S, I> Ord for NonExhaustive<E, S, I>
impl<E, S, I> Ord for NonExhaustive<E, S, I>
source§impl<E, S, I> PartialEq<E> for NonExhaustive<E, S, I>
impl<E, S, I> PartialEq<E> for NonExhaustive<E, S, I>
source§impl<E, S, I1, I2> PartialEq<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>
impl<E, S, I1, I2> PartialEq<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>
source§fn eq(&self, other: &NonExhaustive<E, S, I2>) -> bool
fn eq(&self, other: &NonExhaustive<E, S, I2>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<E, S, I> PartialOrd<E> for NonExhaustive<E, S, I>where
E: GetEnumInfo + PartialOrd,
I: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<E>,
impl<E, S, I> PartialOrd<E> for NonExhaustive<E, S, I>where
E: GetEnumInfo + PartialOrd,
I: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<E>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<E, S, I1, I2> PartialOrd<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>where
I1: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<NonExhaustive<E, S, I2>>,
impl<E, S, I1, I2> PartialOrd<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>where
I1: InterfaceType<PartialOrd = Implemented<PartialOrd>>,
Self: PartialEq<NonExhaustive<E, S, I2>>,
source§fn partial_cmp(&self, other: &NonExhaustive<E, S, I2>) -> Option<Ordering>
fn partial_cmp(&self, other: &NonExhaustive<E, S, I2>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<E, S, I> Serialize for NonExhaustive<E, S, I>
impl<E, S, I> Serialize for NonExhaustive<E, S, I>
First it serializes a NonExhaustive<_>
into a proxy,then it serializes that proxy.
source§impl<E, S, I> StableAbi for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
<E as NonExhaustiveMarker<S>>::Marker: __StableAbi,
impl<E, S, I> StableAbi for NonExhaustive<E, S, I>where
E: __GetStaticEquivalent_ + NonExhaustiveMarker<S>,
S: __GetStaticEquivalent_,
I: __GetStaticEquivalent_ + InterfaceType,
NonExhaustiveVtable_Ref<E, S, I>: StableAbi,
<E as NonExhaustiveMarker<S>>::Marker: __StableAbi,
§type IsNonZeroType = False
type IsNonZeroType = False
source§const LAYOUT: &'static TypeLayout = _
const LAYOUT: &'static TypeLayout = _
source§const ABI_CONSTS: AbiConsts = _
const ABI_CONSTS: AbiConsts = _
const
-equivalents of the associated types.impl<E, S, I> Eq for NonExhaustive<E, S, I>
Auto Trait Implementations§
impl<E, S, I> RefUnwindSafe for NonExhaustive<E, S, I>
impl<E, S, I> Send for NonExhaustive<E, S, I>
impl<E, S, I> Sync for NonExhaustive<E, S, I>
impl<E, S, I> Unpin for NonExhaustive<E, S, I>
impl<E, S, I> UnwindSafe for NonExhaustive<E, S, I>
Blanket Implementations§
source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.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
source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moresource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moresource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moresource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moresource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moresource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moresource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
source§fn piped_ref<'a, F, U>(&'a self, f: F) -> U
fn piped_ref<'a, F, U>(&'a self, f: F) -> U
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moresource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more