1.33.0[][src]Trait frame_support::dispatch::marker::Unpin

#[lang = "unpin"]
pub auto trait Unpin { }

Types that can be safely moved after being pinned.

Since Rust itself has no notion of immovable types, and considers moves (e.g., through assignment or mem::replace) to always be safe, this trait cannot prevent types from moving by itself.

Instead it is used to prevent moves through the type system, by controlling the behavior of pointers P wrapped in the Pin<P> wrapper, which "pin" the type in place by not allowing it to be moved out of them. See the pin module documentation for more information on pinning.

Implementing this trait lifts the restrictions of pinning off a type, which then allows it to move out with functions such as mem::replace.

Unpin has no consequence at all for non-pinned data. In particular, mem::replace happily moves !Unpin data (it works for any &mut T, not just when T: Unpin). However, you cannot use mem::replace on data wrapped inside a Pin<P> because you cannot get the &mut T you need for that, and that is what makes this system work.

So this, for example, can only be done on types implementing Unpin:

use std::mem;
use std::pin::Pin;

let mut string = "this".to_string();
let mut pinned_string = Pin::new(&mut string);

// We need a mutable reference to call `mem::replace`.
// We can obtain such a reference by (implicitly) invoking `Pin::deref_mut`,
// but that is only possible because `String` implements `Unpin`.
mem::replace(&mut *pinned_string, "other".to_string());

This trait is automatically implemented for almost every type.

Implementations on Foreign Types

impl Unpin for Argument

impl Unpin for FormatSpec

impl Unpin for Alignment

impl Unpin for Count

impl Unpin for Position

impl<'a, T> Unpin for &'a mut T where
    T: 'a + ?Sized
[src]

impl Unpin for Waker[src]

impl<'a, T> Unpin for &'a T where
    T: 'a + ?Sized
[src]

impl<T> Unpin for *mut T where
    T: ?Sized
[src]

impl<T> Unpin for *const T where
    T: ?Sized
[src]

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

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

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

impl Unpin for isize

impl Unpin for i8

impl Unpin for i16

impl Unpin for i32

impl Unpin for i64

impl Unpin for i128

impl Unpin for usize

impl Unpin for u8

impl Unpin for u16

impl Unpin for u32

impl Unpin for u64

impl Unpin for u128

impl Unpin for f32

impl Unpin for f64

impl Unpin for bool

impl Unpin for char

impl Unpin for str

impl<T> Unpin for [T] where
    T: Unpin

impl Unpin for [u8]

Loading content...

Implementors

impl !Unpin for PhantomPinned[src]

Loading content...

Auto implementors

impl Unpin for DispatchError

impl Unpin for Never

impl Unpin for frame_support::dispatch::fmt::Alignment

impl Unpin for Void

impl Unpin for RuntimeMetadata

impl Unpin for StorageEntryModifier

impl Unpin for StorageEntryType

impl Unpin for StorageHasher

impl Unpin for ExistenceRequirement

impl Unpin for UpdateBalanceOutcome

impl Unpin for WithdrawReason

impl Unpin for DispatchClass

impl Unpin for SimpleDispatchInfo

impl Unpin for RuntimeLogger

impl Unpin for Writer

impl Unpin for Error

impl Unpin for ErrorMetadata

impl Unpin for FunctionArgumentMetadata

impl Unpin for FunctionMetadata

impl Unpin for ModuleConstantMetadata

impl Unpin for EventMetadata

impl Unpin for OuterEventMetadata

impl Unpin for DefaultByteGetter

impl Unpin for ModuleMetadata

impl Unpin for RuntimeMetadataPrefixed

impl Unpin for StorageEntryMetadata

impl Unpin for StorageMetadata

impl Unpin for Blake2_128

impl Unpin for Blake2_128Concat

impl Unpin for Blake2_256

impl Unpin for Twox128

impl Unpin for Twox256

impl Unpin for Twox64Concat

impl Unpin for WithdrawReasons

impl Unpin for DispatchInfo

impl<'a> Unpin for ChildInfo<'a>

impl<'a> Unpin for Arguments<'a>

impl<'a> Unpin for Formatter<'a>

impl<'a, 'b> Unpin for DebugList<'a, 'b> where
    'b: 'a, 

impl<'a, 'b> Unpin for DebugMap<'a, 'b> where
    'b: 'a, 

impl<'a, 'b> Unpin for DebugSet<'a, 'b> where
    'b: 'a, 

impl<'a, 'b> Unpin for DebugStruct<'a, 'b> where
    'b: 'a, 

impl<'a, 'b> Unpin for DebugTuple<'a, 'b> where
    'b: 'a, 

impl<'a, T> Unpin for Iter<'a, T>

impl<'a, T> Unpin for IterMut<'a, T>

impl<B, O> Unpin for DecodeDifferent<B, O> where
    B: Unpin,
    O: Unpin

impl<B, P> Unpin for SignedImbalance<B, P> where
    P: Unpin,
    <P as Imbalance<B>>::Opposite: Unpin

impl<Balance, Imbalance, Part1, Target1, Part2, Target2> Unpin for SplitTwoWays<Balance, Imbalance, Part1, Target1, Part2, Target2> where
    Balance: Unpin,
    Imbalance: Unpin,
    Part1: Unpin,
    Part2: Unpin,
    Target1: Unpin,
    Target2: Unpin

impl<E> Unpin for FnEncode<E>

impl<K, V, F> Unpin for Enumerator<K, V, F> where
    F: Unpin,
    K: Unpin,
    V: Unpin

impl<Key> Unpin for Linkage<Key> where
    Key: Unpin

impl<T> Unpin for IntoIter<T> where
    T: Unpin

impl<T> Unpin for Vec<T> where
    T: Unpin

impl<T, E> Unpin for Result<T, E> where
    E: Unpin,
    T: Unpin

impl<T: ?Sized> Unpin for PhantomData<T> where
    T: Unpin

impl<Value> Unpin for PrefixIterator<Value> where
    Value: Unpin

Loading content...