#[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>

source

pub const fn new(value: E) -> Self
where 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.

source

pub const fn with_interface(value: E) -> Self
where 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.

source

pub const fn with_storage(value: E) -> Self
where 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.

source

pub const fn with_storage_and_interface(value: E) -> Self
where 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,

source

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);

source

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);
source

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);
source

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.

source

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>

source

pub const unsafe fn transmute_enum<F>(self) -> NonExhaustive<F, S, I>

Transmute this NonExhaustive<E,S,I> into NonExhaustive<F,S,I>, changing the type of the enum it wraps.

Safety

This has the same safety requirements that std::mem::transmute has.

Panics

This panics if the storage has an alignment or size smaller than that of F.

source

pub const unsafe fn transmute_enum_ref<F>(&self) -> &NonExhaustive<F, S, I>

Transmute this &NonExhaustive<E,S,I> into &NonExhaustive<F,S,I>, changing the type of the enum it wraps.

Safety

This has the same safety requirements that std::mem::transmute has.

Panics

This panics if the storage has an alignment or size smaller than that of F.

source

pub unsafe fn transmute_enum_mut<F>(&mut self) -> &mut NonExhaustive<F, S, I>

Transmute this &mut NonExhaustive<E,S,I> into &mut NonExhaustive<F,S,I>, changing the type of the enum it wraps.

Safety

This has the same safety requirements that std::mem::transmute has.

Panics

This panics if the storage has an alignment or size smaller than that of F.

source

pub unsafe fn transmute_enum_ptr<P, F>(this: P) -> P::TransmutedPtr
where P: Deref<Target = Self> + CanTransmuteElement<NonExhaustive<F, S, I>>,

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,

source

pub fn serialize_into_proxy(&self) -> Result<I::Proxy, RBoxError>
where I: InterfaceType<Serialize = Implemented<Serialize>> + SerializeEnum<E>,

It serializes a NonExhaustive<_> into a proxy.

source

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>
where I: InterfaceType<Clone = Implemented<Clone>>,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<E, S, I> Debug for NonExhaustive<E, S, I>
where I: InterfaceType<Debug = Implemented<Debug>>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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>,

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<E, S, I> Display for NonExhaustive<E, S, I>
where I: InterfaceType<Display = Implemented<Display>>,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<E, S, I> Drop for NonExhaustive<E, S, I>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

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)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<E, S, I> GetStaticEquivalent_ for NonExhaustive<E, S, I>

§

type StaticEquivalent = _static_NonExhaustive<<E as GetStaticEquivalent_>::StaticEquivalent, <S as GetStaticEquivalent_>::StaticEquivalent, <I as GetStaticEquivalent_>::StaticEquivalent>

The 'static equivalent of Self
source§

impl<E, S, I> Hash for NonExhaustive<E, S, I>
where I: InterfaceType<Hash = Implemented<Hash>>,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, E, S, I> NonExhaustiveSharedOps for &'a NonExhaustive<E, S, I>
where E: GetEnumInfo,

§

type Discriminant = <E as GetEnumInfo>::Discriminant

The type of the discriminant of the wrapped enum.
source§

fn get_discriminant_(&self) -> E::Discriminant

Gets the discriminant of the wrapped enum.
source§

fn enum_info_(&self) -> &'static EnumInfo

Gets miscelaneous information about the wrapped enum
source§

impl<'a, E, S, I> NonExhaustiveSharedOps for &'a mut NonExhaustive<E, S, I>
where E: GetEnumInfo,

§

type Discriminant = <E as GetEnumInfo>::Discriminant

The type of the discriminant of the wrapped enum.
source§

fn get_discriminant_(&self) -> E::Discriminant

Gets the discriminant of the wrapped enum.
source§

fn enum_info_(&self) -> &'static EnumInfo

Gets miscelaneous information about the wrapped enum
source§

impl<E, S, I> NonExhaustiveSharedOps for NonExhaustive<E, S, I>
where E: GetEnumInfo,

§

type Discriminant = <E as GetEnumInfo>::Discriminant

The type of the discriminant of the wrapped enum.
source§

fn get_discriminant_(&self) -> E::Discriminant

Gets the discriminant of the wrapped enum.
source§

fn enum_info_(&self) -> &'static EnumInfo

Gets miscelaneous information about the wrapped enum
source§

impl<E, S, I> Ord for NonExhaustive<E, S, I>
where I: InterfaceType<Ord = Implemented<Ord>>, Self: PartialOrd + Eq,

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<E, S, I> PartialEq<E> for NonExhaustive<E, S, I>

source§

fn eq(&self, other: &E) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<E, S, I1, I2> PartialEq<NonExhaustive<E, S, I2>> for NonExhaustive<E, S, I1>
where I1: InterfaceType<PartialEq = Implemented<PartialEq>>,

source§

fn eq(&self, other: &NonExhaustive<E, S, I2>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<E, S, I> PartialOrd<E> for NonExhaustive<E, S, I>
where E: GetEnumInfo + PartialOrd, I: InterfaceType<PartialOrd = Implemented<PartialOrd>>, Self: PartialEq<E>,

source§

fn partial_cmp(&self, other: &E) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

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>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<E, S, I> Serialize for NonExhaustive<E, S, I>

First it serializes a NonExhaustive<_> into a proxy,then it serializes that proxy.

source§

fn serialize<Z>(&self, serializer: Z) -> Result<Z::Ok, Z::Error>
where Z: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<E, S, I> StableAbi for NonExhaustive<E, S, I>

§

type IsNonZeroType = False

Whether this type has a single invalid bit-pattern. Read more
source§

const LAYOUT: &'static TypeLayout = _

The layout of the type provided by implementors.
source§

const ABI_CONSTS: AbiConsts = _

const-equivalents of the associated types.
source§

impl<E, S, I> Eq for NonExhaustive<E, S, I>
where Self: PartialEq, I: InterfaceType<Eq = Implemented<Eq>>,

Auto Trait Implementations§

§

impl<E, S, I> RefUnwindSafe for NonExhaustive<E, S, I>

§

impl<E, S, I> Send for NonExhaustive<E, S, I>
where E: Send + Sync, I: Sync, S: Send + Sync,

§

impl<E, S, I> Sync for NonExhaustive<E, S, I>
where E: Sync, I: Sync, S: Sync,

§

impl<E, S, I> Unpin for NonExhaustive<E, S, I>
where E: Unpin, S: Unpin,

§

impl<E, S, I> UnwindSafe for NonExhaustive<E, S, I>

Blanket Implementations§

source§

impl<T> AlignerFor<1> for T

§

type Aligner = AlignTo1<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<1024> for T

§

type Aligner = AlignTo1024<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<128> for T

§

type Aligner = AlignTo128<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<16> for T

§

type Aligner = AlignTo16<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<16384> for T

§

type Aligner = AlignTo16384<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<2> for T

§

type Aligner = AlignTo2<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<2048> for T

§

type Aligner = AlignTo2048<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<256> for T

§

type Aligner = AlignTo256<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<32> for T

§

type Aligner = AlignTo32<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<32768> for T

§

type Aligner = AlignTo32768<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<4> for T

§

type Aligner = AlignTo4<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<4096> for T

§

type Aligner = AlignTo4096<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<512> for T

§

type Aligner = AlignTo512<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<64> for T

§

type Aligner = AlignTo64<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<8> for T

§

type Aligner = AlignTo8<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> AlignerFor<8192> for T

§

type Aligner = AlignTo8192<T>

The AlignTo* type which aligns Self to ALIGNMENT.
source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<'a, T> RCowCompatibleRef<'a> for T
where T: Clone + 'a,

§

type RefC = &'a T

The (preferably) ffi-safe equivalent of &Self.
§

type ROwned = T

The owned version of Self::RefC.
source§

fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC

Converts a reference to an FFI-safe type
source§

fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T

Converts an FFI-safe type to a reference
source§

impl<S> ROExtAcc for S

source§

fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F

Gets a reference to a field, determined by offset. Read more
source§

fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F

Gets a muatble reference to a field, determined by offset. Read more
source§

fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F

Gets a const pointer to a field, the field is determined by offset. Read more
source§

fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F

Gets a mutable pointer to a field, determined by offset. Read more
source§

impl<S> ROExtOps<Aligned> for S

source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Aligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> F
where F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
source§

impl<S> ROExtOps<Unaligned> for S

source§

fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F

Replaces a field (determined by offset) with value, returning the previous value of the field. Read more
source§

fn f_swap<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, right: &mut S)

Swaps a field (determined by offset) with the same field in right. Read more
source§

fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> F
where F: Copy,

Gets a copy of a field (determined by offset). The field is determined by offset. Read more
source§

impl<T> SelfOps for T
where T: ?Sized,

source§

fn eq_id(&self, other: &Self) -> bool

Compares the address of self with the address of other. Read more
source§

fn piped<F, U>(self, f: F) -> U
where F: FnOnce(Self) -> U, Self: Sized,

Emulates the pipeline operator, allowing method syntax in more places. Read more
source§

fn piped_ref<'a, F, U>(&'a self, f: F) -> U
where F: FnOnce(&'a Self) -> U,

The same as piped except that the function takes &Self Useful for functions that take &Self instead of Self. Read more
source§

fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U
where F: FnOnce(&'a mut Self) -> U,

The same as 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
where F: FnOnce(&mut Self), Self: Sized,

Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
source§

fn observe<F>(self, f: F) -> Self
where F: FnOnce(&Self), Self: Sized,

Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
source§

fn into_<T>(self) -> T
where Self: Into<T>,

Performs a conversion with Into. using the turbofish .into_::<_>() syntax. Read more
source§

fn as_ref_<T>(&self) -> &T
where Self: AsRef<T>, T: ?Sized,

Performs a reference to reference conversion with AsRef, using the turbofish .as_ref_::<_>() syntax. Read more
source§

fn as_mut_<T>(&mut self) -> &mut T
where Self: AsMut<T>, T: ?Sized,

Performs a mutable reference to mutable reference conversion with AsMut, using the turbofish .as_mut_::<_>() syntax. Read more
source§

fn drop_(self)
where Self: Sized,

Drops self using method notation. Alternative to std::mem::drop. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<This> TransmuteElement for This
where This: ?Sized,

source§

unsafe fn transmute_element<T>( self ) -> <Self as CanTransmuteElement<T>>::TransmutedPtr
where Self: CanTransmuteElement<T>,

Transmutes the element type of this pointer.. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TypeIdentity for T
where T: ?Sized,

§

type Type = T

This is always Self.
source§

fn into_type(self) -> Self::Type
where Self: Sized, Self::Type: Sized,

Converts a value back to the original type.
source§

fn as_type(&self) -> &Self::Type

Converts a reference back to the original type.
source§

fn as_type_mut(&mut self) -> &mut Self::Type

Converts a mutable reference back to the original type.
source§

fn into_type_box(self: Box<Self>) -> Box<Self::Type>

Converts a box back to the original type.
source§

fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>

Converts an Arc back to the original type. Read more
source§

fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>

Converts an Rc back to the original type. Read more
source§

fn from_type(this: Self::Type) -> Self
where Self: Sized, Self::Type: Sized,

Converts a value back to the original type.
source§

fn from_type_ref(this: &Self::Type) -> &Self

Converts a reference back to the original type.
source§

fn from_type_mut(this: &mut Self::Type) -> &mut Self

Converts a mutable reference back to the original type.
source§

fn from_type_box(this: Box<Self::Type>) -> Box<Self>

Converts a box back to the original type.
source§

fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>

Converts an Arc back to the original type.
source§

fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>

Converts an Rc back to the original type.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<This> ValidTag_Bounds for This
where This: Debug + Clone + PartialEq,