# [−][src]Trait alloc::pin::Unpin

    pub auto trait Unpin { }

🔬 This is a nightly-only experimental API. (`pin` #49150)

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 special pointer types like `PinMut`, 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`:

    #![feature(pin)]
    use std::mem::replace;
    use std::pin::PinMut;

    let mut string = "this".to_string();
    let mut pinned_string = PinMut::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 LocalFutureObj<'a, T>`

[src]

###

`impl !Unpin for Pinned`

[src]

###

`impl<'a, T> Unpin for FutureObj<'a, T>`

[src]

## Implementors

###

`impl Unpin for LocalWaker`

[src]

###

`impl Unpin for Waker`

[src]

###

`impl<'a, T> Unpin for &'a T where T: 'a + ?Sized,`

[src]

###

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

[src]

###

`impl<'a, T> Unpin for PinMut<'a, T> where T: ?Sized,`

[src]

###

`impl<T: ?Sized> Unpin for Box<T>`

[src]

###

`impl<T: ?Sized> Unpin for PinBox<T>`

[src]

###

`impl<T: ?Sized> Unpin for Rc<T>`

[src]

###

`impl<T: ?Sized> Unpin for Arc<T>`

[src]

## Auto implementors

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)