Trait wasmer_types::lib::std::marker::Unpin 1.33.0[−][src]
pub auto trait Unpin { }
Expand description
Types that can be safely moved after being pinned.
Rust itself has no notion of immovable types, and considers moves (e.g.,
through assignment or mem::replace
) to always be safe.
The Pin
type is used instead to prevent moves through the type
system. Pointers P<T>
wrapped in the Pin<P<T>>
wrapper can’t be
moved out of. See the pin
module documentation for more information on
pinning.
Implementing the Unpin
trait for T
lifts the restrictions of pinning off
the type, which then allows moving T
out of Pin<P<T>>
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<T>>
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
Implementors
Auto implementors
impl Unpin for ExportIndex
impl Unpin for ExternType
impl Unpin for GlobalInit
impl Unpin for ImportIndex
impl Unpin for Mutability
impl Unpin for Infallible
impl Unpin for RecvTimeoutError
impl Unpin for TryRecvError
impl Unpin for Atomically
impl Unpin for CustomSectionIndex
impl Unpin for DataInitializerLocation
impl Unpin for FunctionIndex
impl Unpin for FunctionType
impl Unpin for GlobalIndex
impl Unpin for GlobalType
impl Unpin for LocalFunctionIndex
impl Unpin for LocalGlobalIndex
impl Unpin for LocalMemoryIndex
impl Unpin for LocalTableIndex
impl Unpin for MemoryIndex
impl Unpin for MemoryType
impl Unpin for OwnedDataInitializer
impl Unpin for PageCountOutOfRange
impl Unpin for SignatureIndex
impl Unpin for TableIndex
impl Unpin for TableInitializer
impl Unpin for VMExternRef
impl Unpin for BorrowError
impl Unpin for BorrowMutError
impl Unpin for FromUtf8Error
impl Unpin for FromUtf16Error
impl Unpin for AtomicBool
impl Unpin for AtomicIsize
impl Unpin for AtomicUsize
impl Unpin for BarrierWaitResult
impl Unpin for WaitTimeoutResult
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 ChunksExact<'a, T>
impl<'a, T> Unpin for ChunksExactMut<'a, T>
impl<'a, T> Unpin for RChunksExact<'a, T>
impl<'a, T> Unpin for RChunksExactMut<'a, T>
impl<'a, T> Unpin for RChunksMut<'a, T>
impl<'a, T, A> Unpin for MemoryView<'a, T, A> where
A: Unpin,
impl<'a, T, F, A> Unpin for DrainFilter<'a, T, F, A> where
F: Unpin,
impl<'a, T, P> Unpin for GroupByMut<'a, T, P> where
P: Unpin,
impl<'a, T, P> Unpin for RSplitNMut<'a, T, P> where
P: Unpin,
impl<'a, T, const N: usize> Unpin for ArrayChunks<'a, T, N>
impl<'a, T, const N: usize> Unpin for ArrayChunksMut<'a, T, N>
impl<'a, T, const N: usize> Unpin for ArrayWindows<'a, T, N>
impl<'a, T: ?Sized> Unpin for MutexGuard<'a, T>
impl<'a, T: ?Sized> Unpin for RwLockReadGuard<'a, T>
impl<'a, T: ?Sized> Unpin for RwLockWriteGuard<'a, T>
impl<'data> Unpin for DataInitializer<'data>
impl<B, C> Unpin for ControlFlow<B, C> where
B: Unpin,
C: Unpin,
impl<F> Unpin for RepeatWith<F> where
F: Unpin,
impl<H> Unpin for BuildHasherDefault<H> where
H: Unpin,
impl<I> Unpin for Flatten<I> where
I: Unpin,
<<I as Iterator>::Item as IntoIterator>::IntoIter: Unpin,
impl<I, U, F> Unpin for FlatMap<I, U, F> where
F: Unpin,
I: Unpin,
<U as IntoIterator>::IntoIter: Unpin,
impl<Idx> Unpin for RangeInclusive<Idx> where
Idx: Unpin,
impl<Idx> Unpin for RangeToInclusive<Idx> where
Idx: Unpin,
impl<K, V> Unpin for BoxedSlice<K, V> where
K: Unpin,
impl<K, V> Unpin for PrimaryMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> Unpin for SecondaryMap<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> Unpin for ArchivableIndexMap<K, V> where
K: Unpin,
V: Unpin,
impl<T> Unpin for TryLockError<T> where
T: Unpin,
impl<T> Unpin for TrySendError<T> where
T: Unpin,
impl<T> Unpin for PackedOption<T> where
T: Unpin,
impl<T> Unpin for ExportType<T> where
T: Unpin,
impl<T> Unpin for ImportType<T> where
T: Unpin,
impl<T> Unpin for Discriminant<T>
impl<T> Unpin for SyncSender<T>
impl<T> Unpin for PoisonError<T> where
T: Unpin,
impl<T> Unpin for MaybeUninit<T> where
T: Unpin,
impl<T, F> Unpin for Successors<T, F> where
F: Unpin,
T: Unpin,
impl<T: ?Sized> Unpin for UnsafeCell<T> where
T: Unpin,
impl<T: ?Sized> Unpin for ManuallyDrop<T> where
T: Unpin,
impl<T: ?Sized> Unpin for PhantomData<T> where
T: Unpin,
impl<Y, R> Unpin for GeneratorState<Y, R> where
R: Unpin,
Y: Unpin,