Struct scoped_arena::ScopeProxy [−][src]
pub struct ScopeProxy<'scope, A: Allocator = Global> { /* fields omitted */ }
Expand description
Proxy for Scope
which allocates memory bound to the scope lifetime and not itself.
This allows to create sub-scopes while keeping references to scoped values.
Does not frees memory and does not drops values moved on scope when dropped.
Parent Scope
will do this.
Implementations
Allocates a block of memory.
Returns a NonNull<u8>
meeting the size and alignment guarantees of layout.
The returned block contents should be considered uninitialized.
Returned block will be deallocated when scope is dropped.
Attempts to allocate a block of memory.
On success, returns a NonNull<u8>
meeting the size and alignment guarantees of layout.
The returned block contents should be considered uninitialized.
Returned block will be deallocated when scope is dropped.
Errors
Returning Err
indicates that memory is exhausted.
Move value onto the scope. Returns mutable reference to value with lifetime equal to ’scope lifetime. Value on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
Places value returned from function onto the scope. Returns mutable reference to value with lifetime equal to scope borrow lifetime. Value on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
Tries to move value onto the scope. On success, returns mutable reference to value with lifetime to equal ’scope lifetime. Value on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
Errors
Returning Err
indicates that memory is exhausted.
Returning Err
contains original value.
pub fn try_to_scope_with<F, T>(
&self,
f: F
) -> Result<&'scope mut T, (AllocError, F)> where
F: FnOnce() -> T,
pub fn try_to_scope_with<F, T>(
&self,
f: F
) -> Result<&'scope mut T, (AllocError, F)> where
F: FnOnce() -> T,
Tries to place value return from function onto the scope. On success, returns mutable reference to value with lifetime equal to scope borrow lifetime. Value on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
Errors
Returning Err
indicates that memory is exhausted.
Returning Err
contains original value.
pub fn to_scope_from_iter<T, I>(&self, iter: I) -> &'scope mut [T] where
I: IntoIterator<Item = T>,
pub fn to_scope_from_iter<T, I>(&self, iter: I) -> &'scope mut [T] where
I: IntoIterator<Item = T>,
Move values from iterator onto the scope. Returns mutable reference to slice with lifetime equal to ’scope lifetime. Values on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
This method allocates memory to hold iterator’s upper bound number of items. See core::iter::Iterator::size_hint
.
It will not consume more items.
This method will always fail for unbound iterators.
pub fn try_to_scope_from_iter<T, I>(
&self,
iter: I
) -> Result<&'scope mut [T], (AllocError, I::IntoIter)> where
I: IntoIterator<Item = T>,
pub fn try_to_scope_from_iter<T, I>(
&self,
iter: I
) -> Result<&'scope mut [T], (AllocError, I::IntoIter)> where
I: IntoIterator<Item = T>,
Tries to move values from iterator onto the scope. On success, returns mutable reference to slice with lifetime equal to ’scope lifetime. Values on scope will be dropped when scope is dropped.
This method is as cheap as allocation if value does not needs dropping as reported by core::mem::needs_drop
.
This method allocates memory to hold iterator’s upper bound number of items. See core::iter::Iterator::size_hint
.
It will not consume more items.
This method will always fail for unbound iterators.
Errors
Returning Err
indicates that memory is exhausted.
Returning Err
contains original iterator.
Reports total memory allocated from underlying allocator by associated arena.