Trait scale_info::prelude::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 NamedFields
impl Unpin for UnnamedFields
impl Unpin for NameAssigned
impl Unpin for NameNotAssigned
impl Unpin for TypeAssigned
impl Unpin for TypeNotAssigned
impl Unpin for PathAssigned
impl Unpin for PathNotAssigned
impl Unpin for TypeDefPrimitive
impl Unpin for PortableForm
impl Unpin for TryReserveError
impl Unpin for FpCategory
impl Unpin for IntErrorKind
impl Unpin for VariantBuilder
impl Unpin for PortableRegistry
impl Unpin for TypeDefPhantom
impl Unpin for DefaultHasher
impl Unpin for RandomState
impl Unpin for NonZeroI16
impl Unpin for NonZeroI32
impl Unpin for NonZeroI64
impl Unpin for NonZeroI128
impl Unpin for NonZeroIsize
impl Unpin for NonZeroU16
impl Unpin for NonZeroU32
impl Unpin for NonZeroU64
impl Unpin for NonZeroU128
impl Unpin for NonZeroUsize
impl Unpin for ParseFloatError
impl Unpin for ParseIntError
impl Unpin for TryFromIntError
impl Unpin for FromUtf8Error
impl Unpin for FromUtf16Error
impl<'a, 'b> Unpin for DebugStruct<'a, 'b> where
'b: 'a,
impl<'a, 'b> Unpin for DebugTuple<'a, 'b> where
'b: 'a,
impl<'a, K, F> Unpin for scale_info::prelude::collections::hash_set::DrainFilter<'a, K, F> where
F: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::btree_map::Entry<'a, K, V> where
K: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::hash_map::Entry<'a, K, V> where
K: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::btree_map::OccupiedEntry<'a, K, V>
impl<'a, K, V> Unpin for scale_info::prelude::collections::btree_map::OccupiedError<'a, K, V> where
V: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::btree_map::VacantEntry<'a, K, V> where
K: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::hash_map::Drain<'a, K, V> where
K: Unpin,
V: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::hash_map::OccupiedEntry<'a, K, V> where
K: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::hash_map::OccupiedError<'a, K, V> where
K: Unpin,
V: Unpin,
impl<'a, K, V> Unpin for scale_info::prelude::collections::hash_map::VacantEntry<'a, K, V> where
K: Unpin,
impl<'a, K, V, F> Unpin for scale_info::prelude::collections::btree_map::DrainFilter<'a, K, V, F> where
F: Unpin,
impl<'a, K, V, F> Unpin for scale_info::prelude::collections::hash_map::DrainFilter<'a, K, V, F> where
F: Unpin,
impl<'a, K, V, S> Unpin for RawEntryMut<'a, K, V, S>
impl<'a, K, V, S> Unpin for RawEntryBuilder<'a, K, V, S>
impl<'a, K, V, S> Unpin for RawEntryBuilderMut<'a, K, V, S>
impl<'a, K, V, S> Unpin for RawOccupiedEntryMut<'a, K, V, S>
impl<'a, K, V, S> Unpin for RawVacantEntryMut<'a, K, V, S>
impl<'a, T> Unpin for DrainSorted<'a, T>
impl<'a, T> Unpin for scale_info::prelude::collections::btree_set::Difference<'a, T>
impl<'a, T> Unpin for scale_info::prelude::collections::btree_set::Intersection<'a, T>
impl<'a, T> Unpin for scale_info::prelude::collections::btree_set::SymmetricDifference<'a, T>
impl<'a, T, F> Unpin for scale_info::prelude::collections::btree_set::DrainFilter<'a, T, F> where
F: Unpin,
impl<'a, T, F> Unpin for scale_info::prelude::collections::linked_list::DrainFilter<'a, T, F> where
F: Unpin,
impl<'a, T, F, A> Unpin for scale_info::prelude::vec::DrainFilter<'a, T, F, A> where
F: Unpin,
impl<'a, T, S> Unpin for scale_info::prelude::collections::hash_set::Difference<'a, T, S>
impl<'a, T, S> Unpin for scale_info::prelude::collections::hash_set::Intersection<'a, T, S>
impl<'a, T, S> Unpin for scale_info::prelude::collections::hash_set::SymmetricDifference<'a, T, S>
impl<H> Unpin for BuildHasherDefault<H> where
H: Unpin,
impl<K, V> Unpin for scale_info::prelude::collections::btree_map::IntoValues<K, V>
impl<K, V> Unpin for scale_info::prelude::collections::hash_map::IntoIter<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> Unpin for scale_info::prelude::collections::hash_map::IntoKeys<K, V> where
K: Unpin,
V: Unpin,
impl<K, V> Unpin for scale_info::prelude::collections::hash_map::IntoValues<K, V> where
K: Unpin,
V: Unpin,
impl<N, T> Unpin for FieldBuilder<N, T>
impl<S> Unpin for TypeBuilder<S>
impl<T> Unpin for FieldsBuilder<T>
impl<T> Unpin for UntrackedSymbol<T>
impl<T> Unpin for TypeDefArray<T> where
<T as Form>::Type: Unpin,
impl<T> Unpin for TypeDefBitSequence<T> where
<T as Form>::Type: Unpin,
impl<T> Unpin for TypeDefCompact<T> where
<T as Form>::Type: Unpin,
impl<T> Unpin for TypeDefSequence<T> where
<T as Form>::Type: Unpin,
impl<T> Unpin for TypeDefTuple<T> where
<T as Form>::Type: Unpin,
impl<T> Unpin for IntoIterSorted<T> where
T: Unpin,
impl<T> Unpin for BinaryHeap<T> where
T: Unpin,
impl<T> Unpin for LinkedList<T>
impl<T> Unpin for Discriminant<T>
impl<T> Unpin for MaybeUninit<T> where
T: Unpin,
impl<T: ?Sized> Unpin for ManuallyDrop<T> where
T: Unpin,
impl<T: ?Sized> Unpin for PhantomData<T> where
T: Unpin,