1.33.0[][src]Trait boolean_enums::lstd::prelude::v1::Unpin

pub auto trait Unpin { }

Types which can be safely moved after being pinned.

Since Rust itself has no notion of immovable types, and will consider moves to always be safe, this trait cannot prevent types from moving by itself.

Instead it can be used to prevent moves through the type system, by controlling the behavior of pointers wrapped in the Pin 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 replace.

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

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

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

// dereferencing the pointer mutably is only possible because String implements Unpin
replace(&mut *pinned_string, "other".to_string());

This trait is automatically implemented for almost every type.

Implementations on Foreign Types

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

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

Loading content...

Implementors

impl !Unpin for PhantomPinned
[src]

impl Unpin for LocalWaker
[src]

impl Unpin for Waker
[src]

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

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

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

Loading content...

Auto implementors

Loading content...