1.33.0[−][src]Trait ontio_std::prelude::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 Waker[src]
impl !Unpin for PhantomPinned[src]
impl<T> Unpin for Arc<T> where
T: ?Sized, [src]
T: ?Sized,
impl<T> Unpin for Rc<T> where
T: ?Sized, [src]
Loading content...
T: ?Sized,
Implementors
impl<'a, T> Unpin for &'a T where
T: 'a + ?Sized, [src]
T: 'a + ?Sized,
impl<'a, T> Unpin for &'a mut T where
T: 'a + ?Sized, [src]
T: 'a + ?Sized,
impl<T> Unpin for *const T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Unpin for *mut T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Unpin for Box<T> where
T: ?Sized, [src]
T: ?Sized,
Auto implementors
impl Unpin for Error
impl Unpin for Ordering
impl Unpin for SearchStep
impl Unpin for EventBuilder
impl Unpin for Sink
impl Unpin for TransferParam
impl Unpin for ParseBoolError
impl Unpin for Utf8Error
impl Unpin for FromUtf16Error
impl Unpin for FromUtf8Error
impl Unpin for String
impl Unpin for H160
impl Unpin for H256
impl Unpin for [u8]
impl Unpin for bool
impl Unpin for char
impl Unpin for f32
impl Unpin for f64
impl Unpin for i8
impl Unpin for i16
impl Unpin for i32
impl Unpin for i64
impl Unpin for i128
impl Unpin for isize
impl Unpin for str
impl Unpin for u8
impl Unpin for u16
impl Unpin for u32
impl Unpin for u64
impl Unpin for u128
impl Unpin for usize
impl<'a> Unpin for Source<'a>
impl<'a> Unpin for CharSearcher<'a>
impl<'a> Unpin for Bytes<'a>
impl<'a> Unpin for CharIndices<'a>
impl<'a> Unpin for Chars<'a>
impl<'a> Unpin for EncodeUtf16<'a>
impl<'a> Unpin for EscapeDebug<'a>
impl<'a> Unpin for EscapeDefault<'a>
impl<'a> Unpin for EscapeUnicode<'a>
impl<'a> Unpin for Lines<'a>
impl<'a> Unpin for LinesAny<'a>
impl<'a> Unpin for SplitAsciiWhitespace<'a>
impl<'a> Unpin for SplitWhitespace<'a>
impl<'a> Unpin for ontio_std::prelude::string::Drain<'a>
impl<'a, 'b> Unpin for CharSliceSearcher<'a, 'b>
impl<'a, 'b> Unpin for StrSearcher<'a, 'b>
impl<'a, F> Unpin for CharPredicateSearcher<'a, F> where
F: MultiCharEq + Unpin,
F: MultiCharEq + Unpin,
impl<'a, I> Unpin for Splice<'a, I> where
I: Unpin,
I: Unpin,
impl<'a, P> Unpin for MatchIndices<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for Matches<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for RMatchIndices<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for RMatches<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for RSplit<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for RSplitN<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for RSplitTerminator<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for Split<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for SplitN<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, P> Unpin for SplitTerminator<'a, P> where
<P as Pattern<'a>>::Searcher: Unpin,
<P as Pattern<'a>>::Searcher: Unpin,
impl<'a, T> Unpin for ontio_std::prelude::vec::Drain<'a, T>
impl<'a, T, F> Unpin for DrainFilter<'a, T, F> where
F: Unpin,
F: Unpin,
impl<T> Unpin for Option<T> where
T: Unpin,
T: Unpin,
impl<T> Unpin for ListStore<T> where
T: Unpin,
T: Unpin,
impl<T> Unpin for Reverse<T> where
T: Unpin,
T: Unpin,
impl<T> Unpin for IntoIter<T> where
T: Unpin,
T: Unpin,
impl<T> Unpin for Vec<T> where
T: Unpin,
T: Unpin,
impl<T> Unpin for [T] where
T: Unpin,
T: Unpin,
impl<T, E> Unpin for Result<T, E> where
E: Unpin,
T: Unpin,
E: Unpin,
T: Unpin,