#[repr(transparent)]pub struct OnStack<'a, T: ?Sized> { /* private fields */ }
Expand description
A pointer type that uniquely owns its data on the stack. but via the
implementation of a mutable reference to its ManuallyDrop
wrapped form.
This object behaves just like Box<T>
, aside from the fact that its pointed
value is stored somewhere else on the stack, while the storage place itself
is directly unreachable.
See the module level documentation for more information.
Implementations§
source§impl<'a, T: ?Sized> OnStack<'a, T>
impl<'a, T: ?Sized> OnStack<'a, T>
sourcepub unsafe fn new_unchecked(inner: &'a mut ManuallyDrop<T>) -> Self
pub unsafe fn new_unchecked(inner: &'a mut ManuallyDrop<T>) -> Self
sourcepub fn into_raw(pointer: Self) -> *mut T
pub fn into_raw(pointer: Self) -> *mut T
Consumes the OnStack
pointer, returning a wrapped raw pointer, which
will be properly aligned and non-null.
This function behaves just like Box::into_raw
, aside from the fact
that the pointer’s lifetime is discarded as well.
sourcepub unsafe fn from_raw(pointer: *mut T) -> Self
pub unsafe fn from_raw(pointer: *mut T) -> Self
Constructs an OnStack
pointer from a raw pointer.
Safety
Beside the basic requirement stated in
new_unchecked
, the caller must also ensure
the satisfaction of creating a unique & valid reference from this
pointer.
sourcepub fn into_pin(pointer: Self) -> Pin<OnStack<'a, T>>
pub fn into_pin(pointer: Self) -> Pin<OnStack<'a, T>>
Converts a OnStack<T>
into a Pin<OnStack<T>>
. If T
does not
implement Unpin, then *pointer
will be pinned in memory and unable
to be moved.
See opin
for methods that directly pin values.
sourcepub fn leak(pointer: Self) -> &'a mut T
pub fn leak(pointer: Self) -> &'a mut T
Consumes and leaks the OnStack
pointer, returning a mutable reference,
&'a mut T
.
Unlike Box::leak
, this function cannot chose its own lifetime,
because the pointer itself is constrained by a certain lifetime.
Like Box::leak
, the destructor of the value will not be run.
source§impl<'a, T> OnStack<'a, MaybeUninit<T>>
impl<'a, T> OnStack<'a, MaybeUninit<T>>
sourcepub unsafe fn assume_init(self) -> OnStack<'a, T> ⓘ
pub unsafe fn assume_init(self) -> OnStack<'a, T> ⓘ
Converts to an initialized OnStack
pointer.
Safety
As with MaybeUninit::assume_init
, it is up to the caller to
guarantee that the value really is in an initialized state. Calling
this when the content is not yet fully initialized causes immediate
undefined behavior.
source§impl<'a, T> OnStack<'a, MaybeUninit<T>>
impl<'a, T> OnStack<'a, MaybeUninit<T>>
Trait Implementations§
source§impl<'a, T: ?Sized> BorrowMut<T> for OnStack<'a, T>
impl<'a, T: ?Sized> BorrowMut<T> for OnStack<'a, T>
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<'a, A, T: ?Sized + Coroutine<A> + Unpin> Coroutine<A> for OnStack<'a, T>
impl<'a, A, T: ?Sized + Coroutine<A> + Unpin> Coroutine<A> for OnStack<'a, T>
§type Yield = <T as Coroutine<A>>::Yield
type Yield = <T as Coroutine<A>>::Yield
coroutine_trait
)source§impl<'a, T: ?Sized + DoubleEndedIterator> DoubleEndedIterator for OnStack<'a, T>
impl<'a, T: ?Sized + DoubleEndedIterator> DoubleEndedIterator for OnStack<'a, T>
source§fn next_back(&mut self) -> Option<Self::Item>
fn next_back(&mut self) -> Option<Self::Item>
source§fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
iter_advance_by
)n
elements. Read more1.37.0 · source§fn nth_back(&mut self, n: usize) -> Option<Self::Item>
fn nth_back(&mut self, n: usize) -> Option<Self::Item>
n
th element from the end of the iterator. Read more1.27.0 · source§fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
Iterator::try_fold()
: it takes
elements starting from the back of the iterator. Read moresource§impl<'a, T: ?Sized + Error> Error for OnStack<'a, T>
impl<'a, T: ?Sized + Error> Error for OnStack<'a, T>
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
source§fn provide<'b>(&'b self, request: &mut Request<'b>)
fn provide<'b>(&'b self, request: &mut Request<'b>)
error_generic_member_access
)1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl<'a, T: ?Sized + ExactSizeIterator> ExactSizeIterator for OnStack<'a, T>
impl<'a, T: ?Sized + ExactSizeIterator> ExactSizeIterator for OnStack<'a, T>
source§impl<T: ?Sized + Hasher> Hasher for OnStack<'_, T>
impl<T: ?Sized + Hasher> Hasher for OnStack<'_, T>
source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128
into this hasher.source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
usize
into this hasher.source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128
into this hasher.source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
isize
into this hasher.source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras
)source§impl<'a, T> IntoInner for OnStack<'a, T>
impl<'a, T> IntoInner for OnStack<'a, T>
source§fn into_inner(self) -> T
fn into_inner(self) -> T
source§impl<'a, T: ?Sized + Iterator> Iterator for OnStack<'a, T>
impl<'a, T: ?Sized + Iterator> Iterator for OnStack<'a, T>
source§fn next(&mut self) -> Option<Self::Item>
fn next(&mut self) -> Option<Self::Item>
source§fn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk
)N
values. Read more1.0.0 · source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
1.0.0 · source§fn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
1.0.0 · source§fn last(self) -> Option<Self::Item>where
Self: Sized,
fn last(self) -> Option<Self::Item>where
Self: Sized,
source§fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
fn advance_by(&mut self, n: usize) -> Result<(), NonZeroUsize>
iter_advance_by
)n
elements. Read more1.0.0 · source§fn nth(&mut self, n: usize) -> Option<Self::Item>
fn nth(&mut self, n: usize) -> Option<Self::Item>
n
th element of the iterator. Read more1.28.0 · source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
1.0.0 · source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
1.0.0 · source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
source§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
iter_intersperse
)separator
between adjacent items of the original iterator. Read more1.0.0 · source§fn map<B, F>(self, f: F) -> Map<Self, F>
fn map<B, F>(self, f: F) -> Map<Self, F>
1.0.0 · source§fn filter<P>(self, predicate: P) -> Filter<Self, P>
fn filter<P>(self, predicate: P) -> Filter<Self, P>
1.0.0 · source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
1.0.0 · source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
1.0.0 · source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
1.0.0 · source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
1.57.0 · source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
1.0.0 · source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n
elements. Read more1.0.0 · source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n
elements, or fewer
if the underlying iterator ends sooner. Read more1.0.0 · source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
source§fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
iter_map_windows
)f
for each contiguous window of size N
over
self
and returns an iterator over the outputs of f
. Like slice::windows()
,
the windows during mapping overlap as well. Read more1.0.0 · source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
source§fn collect_into<E>(self, collection: &mut E) -> &mut E
fn collect_into<E>(self, collection: &mut E) -> &mut E
iter_collect_into
)1.0.0 · source§fn partition<B, F>(self, f: F) -> (B, B)
fn partition<B, F>(self, f: F) -> (B, B)
source§fn is_partitioned<P>(self, predicate: P) -> bool
fn is_partitioned<P>(self, predicate: P) -> bool
iter_is_partitioned
)true
precede all those that return false
. Read more1.27.0 · source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 · source§fn try_for_each<F, R>(&mut self, f: F) -> R
fn try_for_each<F, R>(&mut self, f: F) -> R
1.0.0 · source§fn fold<B, F>(self, init: B, f: F) -> B
fn fold<B, F>(self, init: B, f: F) -> B
1.51.0 · source§fn reduce<F>(self, f: F) -> Option<Self::Item>
fn reduce<F>(self, f: F) -> Option<Self::Item>
source§fn try_reduce<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
fn try_reduce<F, R>( &mut self, f: F ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
iterator_try_reduce
)1.0.0 · source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
1.0.0 · source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
1.0.0 · source§fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
1.30.0 · source§fn find_map<B, F>(&mut self, f: F) -> Option<B>
fn find_map<B, F>(&mut self, f: F) -> Option<B>
source§fn try_find<F, R>(
&mut self,
f: F
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
fn try_find<F, R>( &mut self, f: F ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
try_find
)1.0.0 · source§fn position<P>(&mut self, predicate: P) -> Option<usize>
fn position<P>(&mut self, predicate: P) -> Option<usize>
1.6.0 · source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · source§fn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
1.6.0 · source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · source§fn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
1.0.0 · source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
1.36.0 · source§fn copied<'a, T>(self) -> Copied<Self>
fn copied<'a, T>(self) -> Copied<Self>
source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
iter_array_chunks
)N
elements of the iterator at a time. Read more1.11.0 · source§fn product<P>(self) -> P
fn product<P>(self) -> P
source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
iter_order_by
)Iterator
with those
of another with respect to the specified comparison function. Read more1.5.0 · source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
PartialOrd
elements of
this Iterator
with those of another. The comparison works like short-circuit
evaluation, returning a result without comparing the remaining elements.
As soon as an order can be determined, the evaluation stops and a result is returned. Read moresource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by
)Iterator
with those
of another with respect to the specified comparison function. Read moresource§fn eq_by<I, F>(self, other: I, eq: F) -> bool
fn eq_by<I, F>(self, other: I, eq: F) -> bool
iter_order_by
)1.5.0 · source§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
Iterator
are lexicographically
less than those of another. Read more1.5.0 · source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
Iterator
are lexicographically
less or equal to those of another. Read more1.5.0 · source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
Iterator
are lexicographically
greater than those of another. Read more1.5.0 · source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
Iterator
are lexicographically
greater than or equal to those of another. Read moresource§fn is_sorted_by<F>(self, compare: F) -> bool
fn is_sorted_by<F>(self, compare: F) -> bool
is_sorted
)source§fn is_sorted_by_key<F, K>(self, f: F) -> bool
fn is_sorted_by_key<F, K>(self, f: F) -> bool
is_sorted
)source§impl<T: ?Sized + Ord> Ord for OnStack<'_, T>
impl<T: ?Sized + Ord> Ord for OnStack<'_, T>
source§impl<T: ?Sized + PartialEq> PartialEq for OnStack<'_, T>
impl<T: ?Sized + PartialEq> PartialEq for OnStack<'_, T>
source§impl<T: ?Sized + PartialOrd> PartialOrd for OnStack<'_, T>
impl<T: ?Sized + PartialOrd> PartialOrd for OnStack<'_, T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, T: ?Sized> RawConvertable for OnStack<'a, T>
impl<'a, T: ?Sized> RawConvertable for OnStack<'a, T>
source§fn into_raw(this: Self) -> (NonNull<T>, ())
fn into_raw(this: Self) -> (NonNull<T>, ())
Consumes the OnStack
pointer, returning a wrapped raw pointer, which
will be properly aligned and non-null.
This function behaves just like Box::into_raw
, aside from the fact
that the pointer’s lifetime is discarded as well.
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<OnStack<'a, U>> for OnStack<'a, T>
impl<'a, T, U: ?Sized> DispatchFromDyn<OnStack<'a, U>> for OnStack<'a, T>
impl<T: ?Sized + Eq> Eq for OnStack<'_, T>
impl<'a, T: ?Sized + FusedIterator> FusedIterator for OnStack<'a, T>
impl<'a, T: ?Sized> Unpin for OnStack<'a, T>
impl<'a, T: ?Sized + UnwindSafe> UnwindSafe for OnStack<'a, T>
Auto Trait Implementations§
impl<'a, T: ?Sized> RefUnwindSafe for OnStack<'a, T>where
T: RefUnwindSafe,
impl<'a, T: ?Sized> Send for OnStack<'a, T>where
T: Send,
impl<'a, T: ?Sized> Sync for OnStack<'a, T>where
T: Sync,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
source§impl<I> IntoIterator for Iwhere
I: Iterator,
impl<I> IntoIterator for Iwhere
I: Iterator,
source§impl<'a, F> Pattern<'a> for F
impl<'a, F> Pattern<'a> for F
§type Searcher = CharPredicateSearcher<'a, F>
type Searcher = CharPredicateSearcher<'a, F>
pattern
)source§fn into_searcher(self, haystack: &'a str) -> CharPredicateSearcher<'a, F>
fn into_searcher(self, haystack: &'a str) -> CharPredicateSearcher<'a, F>
pattern
)self
and the haystack
to search in.source§fn is_contained_in(self, haystack: &'a str) -> bool
fn is_contained_in(self, haystack: &'a str) -> bool
pattern
)source§fn is_prefix_of(self, haystack: &'a str) -> bool
fn is_prefix_of(self, haystack: &'a str) -> bool
pattern
)source§fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str>
fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str>
pattern
)source§fn is_suffix_of(self, haystack: &'a str) -> boolwhere
CharPredicateSearcher<'a, F>: ReverseSearcher<'a>,
fn is_suffix_of(self, haystack: &'a str) -> boolwhere
CharPredicateSearcher<'a, F>: ReverseSearcher<'a>,
pattern
)source§fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str>where
CharPredicateSearcher<'a, F>: ReverseSearcher<'a>,
fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str>where
CharPredicateSearcher<'a, F>: ReverseSearcher<'a>,
pattern
)