[][src]Struct structural::field::ownership::MovedOutFields

pub struct MovedOutFields(_);

Which fields have been moved out of a value.

This is used to implement converting a value into multiple fields by value.

Example

This is a toy example, for more realistic examples,you can look at the manual implementation example of IntoField ,or the manual implementation example of IntoVariantField .

use structural::field::{MovedOutFields, FieldBit};

// This is how `FieldBit` is constructed in the derive macro.
const FIELD_A_BIT: FieldBit= FieldBit::new(0);
const FIELD_B_BIT: FieldBit= FieldBit::new(1);

let mut moved = MovedOutFields::new();

// A `MovedOutFields` considers no field moved when constructed.
assert!( !moved.is_moved_out(FIELD_A_BIT) );
assert!( !moved.is_moved_out(FIELD_B_BIT) );

// `set_moved_out` is called in the
// `IntoField::move_out_field_`/`IntoVariantField::move_out_vfield_` implementation.
moved.set_moved_out(FIELD_A_BIT);
moved.set_moved_out(FIELD_B_BIT);

// `is_moved_out` is called in the `DropFields::drop_fields` implementation,
//
// If `is_moved_out` returns false, then a field has not been moved out,
// and must be dropped.
assert!( moved.is_moved_out(FIELD_A_BIT) );
assert!( moved.is_moved_out(FIELD_B_BIT) );

Implementations

impl MovedOutFields[src]

pub const fn new() -> Self[src]

Constructs a MovedOutFields where no field is considered moved out yet.

pub fn set_moved_out(&mut self, bit: FieldBit)[src]

Marks a field as being moved out.

pub const fn is_moved_out(&self, bit: FieldBit) -> bool[src]

Checks whether a field has been moved out.

Trait Implementations

impl Clone for MovedOutFields[src]

impl Copy for MovedOutFields[src]

impl Debug for MovedOutFields[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<This, T> Array0<T> for This where
    This: ?Sized
[src]

impl<This, V, T> Array0Variant<T, V> for This where
    This: ?Sized
[src]

impl<This, T> ArrayMove0<T> for This where
    This: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<This, T> IntoStructural<T> for This where
    T: FromStructural<This>, 
[src]

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The error type returned when the conversion fails.

impl<This, T> TryIntoStructural<T> for This where
    T: TryFromStructural<This>, 
[src]

type Error = <T as TryFromStructural<This>>::Error

The error parameter of TryFromError, returned from try_into_structural on conversion error. Read more

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more