pub struct Bump<A = Global, S = BumpSettings>where
A: Allocator,
S: BumpAllocatorSettings,{ /* private fields */ }Expand description
The bump allocator.
§Generic parameters
A— the base allocator, defaults toGlobalwhen theallocfeature is enabledS— the bump allocator settings, seesettings
§Overview
All of the mentioned methods that do allocations panic if the base allocator returned an error.
For every such panicking method, there is a corresponding try_-prefixed version that returns a Result instead.
§Create a Bump …
- without allocating a chunk:
new(_in)/default - provide a size hint:
with_size(_in) - provide a minimum capacity:
with_capacity(_in)
§Allocate …
-
sized values:
alloc,alloc_with,alloc_default,alloc_zeroed -
c strings:
alloc_cstr,alloc_cstr_from_str,alloc_cstr_fmt(_mut) -
slices:
alloc_slice_{copy, clone, move, fill, fill_with},alloc_zeroed_slice -
slices from an iterator:
alloc_iter,alloc_iter_exact,alloc_iter_mut,alloc_iter_mut_rev -
uninitialized values:
alloc_uninit,alloc_uninit_slice,alloc_uninit_slice_forwhich can then be conveniently initialized by the
init*methods ofBumpBox. -
results:
alloc_try_with,alloc_try_with_mut -
via clone (nightly only):
alloc_clone
§Free memory using …
- scopes:
scoped,scoped_aligned,scope_guard - checkpoints:
checkpoint,reset_to - reset:
reset - dealloc:
dealloc
§Configure allocator settings …
§Collections
A Bump (and BumpScope) can be used to allocate collections of this crate…
use bump_scope::{Bump, BumpString};
let bump: Bump = Bump::new();
let mut string = BumpString::new_in(&bump);
string.push_str("Hello,");
string.push_str(" world!");… and collections from crates that use allocator_api2’s Allocator like hashbrown’s HashMap:
This requires the allocator-api2-02 feature OR the nightly-allocator-api feature along with hashbrown’s nightly feature.
use bump_scope::Bump;
use hashbrown::HashMap;
let bump: Bump = Bump::new();
let mut map = HashMap::new_in(&bump);
map.insert("tau", 6.283);On nightly and with the feature nightly-allocator-api you can also allocate collections from std that have an allocator parameter:
#![feature(allocator_api, btreemap_alloc)]
use bump_scope::Bump;
use std::collections::{VecDeque, BTreeMap, LinkedList};
let bump: Bump = Bump::new();
let vec = Vec::new_in(&bump);
let queue = VecDeque::new_in(&bump);
let map = BTreeMap::new_in(&bump);
let list = LinkedList::new_in(&bump);§Gotcha
Having live allocations and entering bump scopes at the same time requires a BumpScope.
This is due to the way lifetimes work, since Bump returns allocations with the lifetime
of its own borrow instead of a separate lifetime like BumpScope does.
So you can’t do this:
let mut bump: Bump = Bump::new();
let one = bump.alloc(1);
bump.scoped(|bump| {
// whatever
});But you can make the code work by converting the Bump it to a BumpScope first using as_mut_scope:
let mut bump: Bump = Bump::new();
let bump = bump.as_mut_scope();
let one = bump.alloc(1);
bump.scoped(|bump| {
// whatever
});Implementations§
Source§impl<A, S> Bump<A, S>
Methods for a Bump with a default base allocator.
impl<A, S> Bump<A, S>
Methods for a Bump with a default base allocator.
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new Bump without allocating.
§Examples
use bump_scope::Bump;
let bump: Bump = Bump::new();Sourcepub fn with_size(size: usize) -> Self
pub fn with_size(size: usize) -> Self
Constructs a new Bump with a size hint for the first chunk.
If you want to ensure a specific capacity, use with_capacity instead.
An effort is made to ensure the size requested from the base allocator is friendly to an allocator that uses size classes and stores metadata alongside allocations.
To achieve this, the requested size is rounded up to either the next power of two or the next multiple of 0x1000, whichever is smaller.
After that, the size of [usize; 2] is subtracted.
If the base allocator returns a memory block that is larger than requested, then the chunk will use the extra space.
Disclaimer: The way in which the chunk layout is calculated might change. Such a change is not considered semver breaking.
§Panics
Panics if the allocation fails.
§Examples
use bump_scope::Bump;
// `Bump` with a roughly 1 Mebibyte sized chunk
let bump_1mib: Bump = Bump::with_size(1024 * 1024);Sourcepub fn try_with_size(size: usize) -> Result<Self, AllocError>
pub fn try_with_size(size: usize) -> Result<Self, AllocError>
Constructs a new Bump with a size hint for the first chunk.
If you want to ensure a specific capacity, use try_with_capacity instead.
An effort is made to ensure the size requested from the base allocator is friendly to an allocator that uses size classes and stores metadata alongside allocations.
To achieve this, the requested size is rounded up to either the next power of two or the next multiple of 0x1000, whichever is smaller.
After that, the size of [usize; 2] is subtracted.
If the base allocator returns a memory block that is larger than requested, then the chunk will use the extra space.
Disclaimer: The way in which the chunk layout is calculated might change. Such a change is not considered semver breaking.
§Errors
Errors if the allocation fails.
§Examples
use bump_scope::Bump;
// `Bump` with a roughly 1 Mebibyte sized chunk
let bump_1mib: Bump = Bump::try_with_size(1024 * 1024)?;Sourcepub fn with_capacity(layout: Layout) -> Self
pub fn with_capacity(layout: Layout) -> Self
Constructs a new Bump with at least enough space for layout.
To construct a Bump with a size hint use with_size instead.
§Panics
Panics if the allocation fails.
§Examples
use bump_scope::Bump;
use core::alloc::Layout;
let layout = Layout::array::<u8>(1234).unwrap();
let bump: Bump = Bump::with_capacity(layout);
assert!(bump.stats().capacity() >= layout.size());Sourcepub fn try_with_capacity(layout: Layout) -> Result<Self, AllocError>
pub fn try_with_capacity(layout: Layout) -> Result<Self, AllocError>
Constructs a new Bump with at least enough space for layout.
To construct a Bump with a size hint use try_with_size instead.
§Errors
Errors if the allocation fails.
§Examples
use bump_scope::Bump;
use core::alloc::Layout;
let layout = Layout::array::<u8>(1234).unwrap();
let bump: Bump = Bump::try_with_capacity(layout)?;
assert!(bump.stats().capacity() >= layout.size());Source§impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Methods that are always available.
impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Methods that are always available.
Sourcepub const fn new_in(allocator: A) -> Self
pub const fn new_in(allocator: A) -> Self
Constructs a new Bump without allocating.
§Examples
use bump_scope::Bump;
use bump_scope::alloc::Global;
let bump: Bump = Bump::new_in(Global);Sourcepub fn with_size_in(size: usize, allocator: A) -> Self
pub fn with_size_in(size: usize, allocator: A) -> Self
Constructs a new Bump with a size hint for the first chunk.
If you want to ensure a specific capacity, use with_capacity_in instead.
An effort is made to ensure the size requested from the base allocator is friendly to an allocator that uses size classes and stores metadata alongside allocations.
To achieve this, the requested size is rounded up to either the next power of two or the next multiple of 0x1000, whichever is smaller.
After that, the size of [usize; 2] is subtracted.
If the base allocator returns a memory block that is larger than requested, then the chunk will use the extra space.
Disclaimer: The way in which the chunk layout is calculated might change. Such a change is not considered semver breaking.
§Panics
Panics if the allocation fails.
§Examples
use bump_scope::Bump;
use bump_scope::alloc::Global;
// `Bump` with a roughly 1 Mebibyte sized chunk
let bump_1mib: Bump = Bump::with_size_in(1024 * 1024, Global);Sourcepub fn try_with_size_in(size: usize, allocator: A) -> Result<Self, AllocError>
pub fn try_with_size_in(size: usize, allocator: A) -> Result<Self, AllocError>
Constructs a new Bump with a size hint for the first chunk.
If you want to ensure a specific capacity, use try_with_capacity instead.
An effort is made to ensure the size requested from the base allocator is friendly to an allocator that uses size classes and stores metadata alongside allocations.
To achieve this, the requested size is rounded up to either the next power of two or the next multiple of 0x1000, whichever is smaller.
After that, the size of [usize; 2] is subtracted.
If the base allocator returns a memory block that is larger than requested, then the chunk will use the extra space.
Disclaimer: The way in which the chunk layout is calculated might change. Such a change is not considered semver breaking.
§Errors
Errors if the allocation fails.
§Examples
use bump_scope::Bump;
use bump_scope::alloc::Global;
// `Bump` with a roughly 1 Mebibyte sized chunk
let bump_1mib: Bump = Bump::try_with_size_in(1024 * 1024, Global)?;Sourcepub fn with_capacity_in(layout: Layout, allocator: A) -> Self
pub fn with_capacity_in(layout: Layout, allocator: A) -> Self
Constructs a new Bump with at least enough space for layout.
To construct a Bump with a size hint use with_size_in instead.
§Panics
Panics if the allocation fails.
§Examples
use bump_scope::Bump;
use bump_scope::alloc::Global;
use core::alloc::Layout;
let layout = Layout::array::<u8>(1234).unwrap();
let bump: Bump = Bump::with_capacity_in(layout, Global);
assert!(bump.stats().capacity() >= layout.size());Sourcepub fn try_with_capacity_in(
layout: Layout,
allocator: A,
) -> Result<Self, AllocError>
pub fn try_with_capacity_in( layout: Layout, allocator: A, ) -> Result<Self, AllocError>
Constructs a new Bump with at least enough space for layout.
To construct a Bump with a size hint use try_with_size_in instead.
§Errors
Errors if the allocation fails.
§Examples
use bump_scope::Bump;
use bump_scope::alloc::Global;
use core::alloc::Layout;
let layout = Layout::array::<u8>(1234).unwrap();
let bump: Bump = Bump::try_with_capacity_in(layout, Global)?;
assert!(bump.stats().capacity() >= layout.size());Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Deallocates every chunk but the newest, which is also the biggest.
use bump_scope::Bump;
let mut bump: Bump = Bump::with_size(512);
// won't fit in the first chunk
bump.alloc_uninit_slice::<u8>(600);
let chunks = bump.stats().small_to_big().collect::<Vec<_>>();
assert_eq!(chunks.len(), 2);
assert!(chunks[0].size() < chunks[1].size());
assert_eq!(chunks[0].allocated(), 0);
assert_eq!(chunks[1].allocated(), 600);
let last_chunk_size = chunks[1].size();
bump.reset();
let chunks = bump.stats().small_to_big().collect::<Vec<_>>();
assert_eq!(chunks.len(), 1);
assert_eq!(chunks[0].size(), last_chunk_size);
assert_eq!(chunks[0].allocated(), 0);Sourcepub fn stats(&self) -> Stats<'_, S>
pub fn stats(&self) -> Stats<'_, S>
Returns a type which provides statistics about the memory usage of the bump allocator.
Sourcepub fn as_mut_scope(&mut self) -> &mut BumpScope<'_, A, S>
pub fn as_mut_scope(&mut self) -> &mut BumpScope<'_, A, S>
Returns this &mut Bump as a &mut BumpScope.
Sourcepub fn with_settings<NewS>(self) -> Bump<A, NewS>where
NewS: BumpAllocatorSettings,
pub fn with_settings<NewS>(self) -> Bump<A, NewS>where
NewS: BumpAllocatorSettings,
Converts this Bump into a Bump with new settings.
Not every setting can be converted to. This function will fail to compile if:
NewS::UP != S::UPNewS::GUARANTEED_ALLOCATED > S::GUARANTEED_ALLOCATEDNewS::CLAIMABLE < S::CLAIMABLE
Sourcepub fn borrow_with_settings<NewS>(&self) -> &Bump<A, NewS>where
NewS: BumpAllocatorSettings,
pub fn borrow_with_settings<NewS>(&self) -> &Bump<A, NewS>where
NewS: BumpAllocatorSettings,
Borrows this Bump with new settings.
Not every settings can be converted to. This function will fail to compile if:
NewS::MIN_ALIGN != S::MIN_ALIGNNewS::UP != S::UPNewS::GUARANTEED_ALLOCATED > S::GUARANTEED_ALLOCATEDNewS::CLAIMABLE != S::CLAIMABLE
Sourcepub fn borrow_mut_with_settings<NewS>(&mut self) -> &mut Bump<A, NewS>where
NewS: BumpAllocatorSettings,
pub fn borrow_mut_with_settings<NewS>(&mut self) -> &mut Bump<A, NewS>where
NewS: BumpAllocatorSettings,
Borrows this Bump mutably with new settings.
Not every settings can be converted to. This function will fail to compile if:
NewS::MIN_ALIGN < S::MIN_ALIGNNewS::UP != S::UPNewS::GUARANTEED_ALLOCATED != S::GUARANTEED_ALLOCATEDNewS::CLAIMABLE != S::CLAIMABLE
Source§impl<S> Bump<Global, S>where
S: BumpAllocatorSettings,
impl<S> Bump<Global, S>where
S: BumpAllocatorSettings,
Sourcepub fn into_raw(self) -> NonNull<()>
Available on crate feature alloc only.
pub fn into_raw(self) -> NonNull<()>
alloc only.Converts this Bump into a raw pointer.
use bump_scope::Bump;
let bump: Bump = Bump::new();
let ptr = bump.into_raw();
let bump: Bump = unsafe { Bump::from_raw(ptr) };
bump.alloc_str("Why did i do this?");Source§impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Methods that forward to traits.
impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Methods that forward to traits.
Sourcepub fn claim(&self) -> BumpClaimGuard<'_, '_, A, S>
pub fn claim(&self) -> BumpClaimGuard<'_, '_, A, S>
Forwards to BumpAllocatorScope::claim.
Sourcepub fn is_claimed(&self) -> bool
pub fn is_claimed(&self) -> bool
Forwards to BumpAllocatorCore::is_claimed.
Sourcepub fn scope_guard(&mut self) -> BumpScopeGuard<'_, A, S>
pub fn scope_guard(&mut self) -> BumpScopeGuard<'_, A, S>
Forwards to BumpAllocator::scope_guard.
Sourcepub fn scoped<R>(&mut self, f: impl FnOnce(&mut BumpScope<'_, A, S>) -> R) -> R
pub fn scoped<R>(&mut self, f: impl FnOnce(&mut BumpScope<'_, A, S>) -> R) -> R
Forwards to BumpAllocator::scoped.
Sourcepub fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
pub fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
Forwards to BumpAllocator::scoped_aligned.
Sourcepub fn aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
pub fn aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
Forwards to BumpAllocatorScope::aligned.
Sourcepub fn checkpoint(&self) -> Checkpoint
pub fn checkpoint(&self) -> Checkpoint
Forwards to BumpAllocatorCore::checkpoint.
Sourcepub unsafe fn reset_to(&self, checkpoint: Checkpoint)
pub unsafe fn reset_to(&self, checkpoint: Checkpoint)
Forwards to BumpAllocatorCore::reset_to.
Sourcepub fn allocator(&self) -> &A
pub fn allocator(&self) -> &A
Forwards to BumpAllocatorScope::allocator.
Sourcepub fn alloc<T>(&self, value: T) -> BumpBox<'_, T> ⓘ
pub fn alloc<T>(&self, value: T) -> BumpBox<'_, T> ⓘ
Forwards to BumpAllocatorTypedScope::alloc.
Sourcepub fn try_alloc<T>(&self, value: T) -> Result<BumpBox<'_, T>, AllocError>
pub fn try_alloc<T>(&self, value: T) -> Result<BumpBox<'_, T>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc.
Sourcepub fn alloc_with<T>(&self, f: impl FnOnce() -> T) -> BumpBox<'_, T> ⓘ
pub fn alloc_with<T>(&self, f: impl FnOnce() -> T) -> BumpBox<'_, T> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_with.
Sourcepub fn try_alloc_with<T>(
&self,
f: impl FnOnce() -> T,
) -> Result<BumpBox<'_, T>, AllocError>
pub fn try_alloc_with<T>( &self, f: impl FnOnce() -> T, ) -> Result<BumpBox<'_, T>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_with.
Sourcepub fn alloc_default<T: Default>(&self) -> BumpBox<'_, T> ⓘ
pub fn alloc_default<T: Default>(&self) -> BumpBox<'_, T> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_default.
Sourcepub fn try_alloc_default<T: Default>(
&self,
) -> Result<BumpBox<'_, T>, AllocError>
pub fn try_alloc_default<T: Default>( &self, ) -> Result<BumpBox<'_, T>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_default.
Sourcepub fn alloc_clone<T: CloneToUninit + ?Sized>(
&self,
value: &T,
) -> BumpBox<'_, T> ⓘ
Available on crate feature nightly-clone-to-uninit only.
pub fn alloc_clone<T: CloneToUninit + ?Sized>( &self, value: &T, ) -> BumpBox<'_, T> ⓘ
nightly-clone-to-uninit only.Forwards to BumpAllocatorTypedScope::alloc_clone.
Sourcepub fn try_alloc_clone<T: CloneToUninit + ?Sized>(
&self,
value: &T,
) -> Result<BumpBox<'_, T>, AllocError>
Available on crate feature nightly-clone-to-uninit only.
pub fn try_alloc_clone<T: CloneToUninit + ?Sized>( &self, value: &T, ) -> Result<BumpBox<'_, T>, AllocError>
nightly-clone-to-uninit only.Forwards to BumpAllocatorTypedScope::try_alloc_clone.
Sourcepub fn alloc_slice_move<T>(
&self,
slice: impl OwnedSlice<Item = T>,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_slice_move<T>( &self, slice: impl OwnedSlice<Item = T>, ) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_slice_move.
Sourcepub fn try_alloc_slice_move<T>(
&self,
slice: impl OwnedSlice<Item = T>,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_slice_move<T>( &self, slice: impl OwnedSlice<Item = T>, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_slice_move.
Sourcepub fn alloc_slice_copy<T: Copy>(&self, slice: &[T]) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_slice_copy<T: Copy>(&self, slice: &[T]) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_slice_copy.
Sourcepub fn try_alloc_slice_copy<T: Copy>(
&self,
slice: &[T],
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_slice_copy<T: Copy>( &self, slice: &[T], ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_slice_copy.
Sourcepub fn alloc_slice_clone<T: Clone>(&self, slice: &[T]) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_slice_clone<T: Clone>(&self, slice: &[T]) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_slice_clone.
Sourcepub fn try_alloc_slice_clone<T: Clone>(
&self,
slice: &[T],
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_slice_clone<T: Clone>( &self, slice: &[T], ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_slice_clone.
Sourcepub fn alloc_slice_fill<T: Clone>(
&self,
len: usize,
value: T,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_slice_fill<T: Clone>( &self, len: usize, value: T, ) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_slice_fill.
Sourcepub fn try_alloc_slice_fill<T: Clone>(
&self,
len: usize,
value: T,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_slice_fill<T: Clone>( &self, len: usize, value: T, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_slice_fill.
Sourcepub fn alloc_slice_fill_with<T>(
&self,
len: usize,
f: impl FnMut() -> T,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_slice_fill_with<T>( &self, len: usize, f: impl FnMut() -> T, ) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_slice_fill_with.
Sourcepub fn try_alloc_slice_fill_with<T>(
&self,
len: usize,
f: impl FnMut() -> T,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_slice_fill_with<T>( &self, len: usize, f: impl FnMut() -> T, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_slice_fill_with.
Sourcepub fn alloc_str(&self, src: &str) -> BumpBox<'_, str> ⓘ
pub fn alloc_str(&self, src: &str) -> BumpBox<'_, str> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_str.
Sourcepub fn try_alloc_str(&self, src: &str) -> Result<BumpBox<'_, str>, AllocError>
pub fn try_alloc_str(&self, src: &str) -> Result<BumpBox<'_, str>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_str.
Sourcepub fn alloc_fmt(&self, args: Arguments<'_>) -> BumpBox<'_, str> ⓘ
pub fn alloc_fmt(&self, args: Arguments<'_>) -> BumpBox<'_, str> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_fmt.
Sourcepub fn try_alloc_fmt(
&self,
args: Arguments<'_>,
) -> Result<BumpBox<'_, str>, AllocError>
pub fn try_alloc_fmt( &self, args: Arguments<'_>, ) -> Result<BumpBox<'_, str>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_fmt.
Sourcepub fn alloc_fmt_mut(&mut self, args: Arguments<'_>) -> BumpBox<'_, str> ⓘ
pub fn alloc_fmt_mut(&mut self, args: Arguments<'_>) -> BumpBox<'_, str> ⓘ
Forwards to MutBumpAllocatorTypedScope::alloc_fmt_mut.
Sourcepub fn try_alloc_fmt_mut(
&mut self,
args: Arguments<'_>,
) -> Result<BumpBox<'_, str>, AllocError>
pub fn try_alloc_fmt_mut( &mut self, args: Arguments<'_>, ) -> Result<BumpBox<'_, str>, AllocError>
Forwards to MutBumpAllocatorTypedScope::try_alloc_fmt_mut.
Sourcepub fn alloc_cstr(&self, src: &CStr) -> &CStr
pub fn alloc_cstr(&self, src: &CStr) -> &CStr
Forwards to BumpAllocatorTypedScope::alloc_cstr.
Sourcepub fn try_alloc_cstr(&self, src: &CStr) -> Result<&CStr, AllocError>
pub fn try_alloc_cstr(&self, src: &CStr) -> Result<&CStr, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_cstr.
Sourcepub fn alloc_cstr_from_str(&self, src: &str) -> &CStr
pub fn alloc_cstr_from_str(&self, src: &str) -> &CStr
Forwards to BumpAllocatorTypedScope::alloc_cstr_from_str.
Sourcepub fn try_alloc_cstr_from_str(&self, src: &str) -> Result<&CStr, AllocError>
pub fn try_alloc_cstr_from_str(&self, src: &str) -> Result<&CStr, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_cstr_from_str.
Sourcepub fn alloc_cstr_fmt(&self, args: Arguments<'_>) -> &CStr
pub fn alloc_cstr_fmt(&self, args: Arguments<'_>) -> &CStr
Forwards to BumpAllocatorTypedScope::alloc_cstr_fmt.
Sourcepub fn try_alloc_cstr_fmt(
&self,
args: Arguments<'_>,
) -> Result<&CStr, AllocError>
pub fn try_alloc_cstr_fmt( &self, args: Arguments<'_>, ) -> Result<&CStr, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_cstr_fmt.
Sourcepub fn alloc_cstr_fmt_mut(&mut self, args: Arguments<'_>) -> &CStr
pub fn alloc_cstr_fmt_mut(&mut self, args: Arguments<'_>) -> &CStr
Forwards to MutBumpAllocatorTypedScope::alloc_cstr_fmt_mut.
Sourcepub fn try_alloc_cstr_fmt_mut(
&mut self,
args: Arguments<'_>,
) -> Result<&CStr, AllocError>
pub fn try_alloc_cstr_fmt_mut( &mut self, args: Arguments<'_>, ) -> Result<&CStr, AllocError>
Forwards to MutBumpAllocatorTypedScope::try_alloc_cstr_fmt_mut.
Sourcepub fn alloc_iter<T>(
&self,
iter: impl IntoIterator<Item = T>,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_iter<T>( &self, iter: impl IntoIterator<Item = T>, ) -> BumpBox<'_, [T]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_iter.
Sourcepub fn try_alloc_iter<T>(
&self,
iter: impl IntoIterator<Item = T>,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_iter<T>( &self, iter: impl IntoIterator<Item = T>, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_iter.
Sourcepub fn alloc_iter_exact<T, I>(
&self,
iter: impl IntoIterator<Item = T, IntoIter = I>,
) -> BumpBox<'_, [T]> ⓘwhere
I: ExactSizeIterator<Item = T>,
pub fn alloc_iter_exact<T, I>(
&self,
iter: impl IntoIterator<Item = T, IntoIter = I>,
) -> BumpBox<'_, [T]> ⓘwhere
I: ExactSizeIterator<Item = T>,
Forwards to BumpAllocatorTypedScope::alloc_iter_exact.
Sourcepub fn try_alloc_iter_exact<T, I>(
&self,
iter: impl IntoIterator<Item = T, IntoIter = I>,
) -> Result<BumpBox<'_, [T]>, AllocError>where
I: ExactSizeIterator<Item = T>,
pub fn try_alloc_iter_exact<T, I>(
&self,
iter: impl IntoIterator<Item = T, IntoIter = I>,
) -> Result<BumpBox<'_, [T]>, AllocError>where
I: ExactSizeIterator<Item = T>,
Forwards to BumpAllocatorTypedScope::try_alloc_iter_exact.
Sourcepub fn alloc_iter_mut<T>(
&mut self,
iter: impl IntoIterator<Item = T>,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_iter_mut<T>( &mut self, iter: impl IntoIterator<Item = T>, ) -> BumpBox<'_, [T]> ⓘ
Forwards to MutBumpAllocatorTypedScope::alloc_iter_mut.
Sourcepub fn try_alloc_iter_mut<T>(
&mut self,
iter: impl IntoIterator<Item = T>,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_iter_mut<T>( &mut self, iter: impl IntoIterator<Item = T>, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to MutBumpAllocatorTypedScope::try_alloc_iter_mut.
Sourcepub fn alloc_iter_mut_rev<T>(
&mut self,
iter: impl IntoIterator<Item = T>,
) -> BumpBox<'_, [T]> ⓘ
pub fn alloc_iter_mut_rev<T>( &mut self, iter: impl IntoIterator<Item = T>, ) -> BumpBox<'_, [T]> ⓘ
Forwards to MutBumpAllocatorTypedScope::alloc_iter_mut_rev.
Sourcepub fn try_alloc_iter_mut_rev<T>(
&mut self,
iter: impl IntoIterator<Item = T>,
) -> Result<BumpBox<'_, [T]>, AllocError>
pub fn try_alloc_iter_mut_rev<T>( &mut self, iter: impl IntoIterator<Item = T>, ) -> Result<BumpBox<'_, [T]>, AllocError>
Forwards to MutBumpAllocatorTypedScope::try_alloc_iter_mut_rev.
Sourcepub fn alloc_uninit<T>(&self) -> BumpBox<'_, MaybeUninit<T>> ⓘ
pub fn alloc_uninit<T>(&self) -> BumpBox<'_, MaybeUninit<T>> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_uninit.
Sourcepub fn try_alloc_uninit<T>(
&self,
) -> Result<BumpBox<'_, MaybeUninit<T>>, AllocError>
pub fn try_alloc_uninit<T>( &self, ) -> Result<BumpBox<'_, MaybeUninit<T>>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_uninit.
Sourcepub fn alloc_uninit_slice<T>(&self, len: usize) -> BumpBox<'_, [MaybeUninit<T>]> ⓘ
pub fn alloc_uninit_slice<T>(&self, len: usize) -> BumpBox<'_, [MaybeUninit<T>]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_uninit_slice.
Sourcepub fn try_alloc_uninit_slice<T>(
&self,
len: usize,
) -> Result<BumpBox<'_, [MaybeUninit<T>]>, AllocError>
pub fn try_alloc_uninit_slice<T>( &self, len: usize, ) -> Result<BumpBox<'_, [MaybeUninit<T>]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_uninit_slice.
Sourcepub fn alloc_uninit_slice_for<T>(
&self,
slice: &[T],
) -> BumpBox<'_, [MaybeUninit<T>]> ⓘ
pub fn alloc_uninit_slice_for<T>( &self, slice: &[T], ) -> BumpBox<'_, [MaybeUninit<T>]> ⓘ
Forwards to BumpAllocatorTypedScope::alloc_uninit_slice_for.
Sourcepub fn try_alloc_uninit_slice_for<T>(
&self,
slice: &[T],
) -> Result<BumpBox<'_, [MaybeUninit<T>]>, AllocError>
pub fn try_alloc_uninit_slice_for<T>( &self, slice: &[T], ) -> Result<BumpBox<'_, [MaybeUninit<T>]>, AllocError>
Forwards to BumpAllocatorTypedScope::try_alloc_uninit_slice_for.
Sourcepub fn dealloc<T: ?Sized>(&self, boxed: BumpBox<'_, T>)
pub fn dealloc<T: ?Sized>(&self, boxed: BumpBox<'_, T>)
Forwards to BumpAllocatorTyped::dealloc.
Sourcepub fn reserve(&self, additional: usize)
pub fn reserve(&self, additional: usize)
Forwards to BumpAllocatorTyped::reserve.
Sourcepub fn try_reserve(&self, additional: usize) -> Result<(), AllocError>
pub fn try_reserve(&self, additional: usize) -> Result<(), AllocError>
Forwards to BumpAllocatorTyped::try_reserve.
Source§impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Additional alloc methods that are not available in traits.
impl<A, S> Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Additional alloc methods that are not available in traits.
Sourcepub fn alloc_try_with<T, E>(
&self,
f: impl FnOnce() -> Result<T, E>,
) -> Result<BumpBox<'_, T>, E>
pub fn alloc_try_with<T, E>( &self, f: impl FnOnce() -> Result<T, E>, ) -> Result<BumpBox<'_, T>, E>
Allocates the result of f in the bump allocator, then moves E out of it and deallocates the space it took up.
This can be more performant than allocating T after the fact, as Result<T, E> may be constructed in the bump allocators memory instead of on the stack and then copied over.
There is also alloc_try_with_mut, optimized for a mutable reference.
§Panics
Panics if the allocation fails.
§Examples
let result = bump.alloc_try_with(|| -> Result<i32, i32> { Ok(123) });
assert_eq!(result.unwrap(), 123);
assert_eq!(bump.stats().allocated(), offset_of!(Result<i32, i32>, Ok.0) + size_of::<i32>());let result = bump.alloc_try_with(|| -> Result<i32, i32> { Err(123) });
assert_eq!(result.unwrap_err(), 123);
assert_eq!(bump.stats().allocated(), 0);Sourcepub fn try_alloc_try_with<T, E>(
&self,
f: impl FnOnce() -> Result<T, E>,
) -> Result<Result<BumpBox<'_, T>, E>, AllocError>
pub fn try_alloc_try_with<T, E>( &self, f: impl FnOnce() -> Result<T, E>, ) -> Result<Result<BumpBox<'_, T>, E>, AllocError>
Allocates the result of f in the bump allocator, then moves E out of it and deallocates the space it took up.
This can be more performant than allocating T after the fact, as Result<T, E> may be constructed in the bump allocators memory instead of on the stack and then copied over.
There is also try_alloc_try_with_mut, optimized for a mutable reference.
§Errors
Errors if the allocation fails.
§Examples
let result = bump.try_alloc_try_with(|| -> Result<i32, i32> { Ok(123) })?;
assert_eq!(result.unwrap(), 123);
assert_eq!(bump.stats().allocated(), offset_of!(Result<i32, i32>, Ok.0) + size_of::<i32>());let result = bump.try_alloc_try_with(|| -> Result<i32, i32> { Err(123) })?;
assert_eq!(result.unwrap_err(), 123);
assert_eq!(bump.stats().allocated(), 0);Sourcepub fn alloc_try_with_mut<T, E>(
&mut self,
f: impl FnOnce() -> Result<T, E>,
) -> Result<BumpBox<'_, T>, E>
pub fn alloc_try_with_mut<T, E>( &mut self, f: impl FnOnce() -> Result<T, E>, ) -> Result<BumpBox<'_, T>, E>
Allocates the result of f in the bump allocator, then moves E out of it and deallocates the space it took up.
This can be more performant than allocating T after the fact, as Result<T, E> may be constructed in the bump allocators memory instead of on the stack and then copied over.
This is just like alloc_try_with, but optimized for a mutable reference.
§Panics
Panics if the allocation fails.
§Examples
let result = bump.alloc_try_with_mut(|| -> Result<i32, i32> { Ok(123) });
assert_eq!(result.unwrap(), 123);
assert_eq!(bump.stats().allocated(), offset_of!(Result<i32, i32>, Ok.0) + size_of::<i32>());let result = bump.alloc_try_with_mut(|| -> Result<i32, i32> { Err(123) });
assert_eq!(result.unwrap_err(), 123);
assert_eq!(bump.stats().allocated(), 0);Sourcepub fn try_alloc_try_with_mut<T, E>(
&mut self,
f: impl FnOnce() -> Result<T, E>,
) -> Result<Result<BumpBox<'_, T>, E>, AllocError>
pub fn try_alloc_try_with_mut<T, E>( &mut self, f: impl FnOnce() -> Result<T, E>, ) -> Result<Result<BumpBox<'_, T>, E>, AllocError>
Allocates the result of f in the bump allocator, then moves E out of it and deallocates the space it took up.
This can be more performant than allocating T after the fact, as Result<T, E> may be constructed in the bump allocators memory instead of on the stack and then copied over.
This is just like try_alloc_try_with, but optimized for a mutable reference.
§Errors
Errors if the allocation fails.
§Examples
let result = bump.try_alloc_try_with_mut(|| -> Result<i32, i32> { Ok(123) })?;
assert_eq!(result.unwrap(), 123);
assert_eq!(bump.stats().allocated(), offset_of!(Result<i32, i32>, Ok.0) + size_of::<i32>());let result = bump.try_alloc_try_with_mut(|| -> Result<i32, i32> { Err(123) })?;
assert_eq!(result.unwrap_err(), 123);
assert_eq!(bump.stats().allocated(), 0);Trait Implementations§
Source§impl<A, S> Allocator for &mut Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
Available on crate feature allocator-api2-03 only.
impl<A, S> Allocator for &mut Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
allocator-api2-03 only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A, S> Allocator for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
impl<A, S> Allocator for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
Available on crate feature nightly-allocator-api only.
impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
nightly-allocator-api only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
allocator_api)Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
allocator_api)ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
allocator_api)Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
allocator_api)grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
allocator_api)Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocator_api)allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
Available on crate feature allocator-api2-03 only.
impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
allocator-api2-03 only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
Available on crate feature allocator-api2-04 only.
impl<A, S> Allocator for Bump<A, S>where
A: CrateAllocator,
S: BumpAllocatorSettings,
allocator-api2-04 only.Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
ptr. Read moreSource§unsafe fn grow(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§unsafe fn grow_zeroed(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn grow_zeroed( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
grow, but also ensures that the new contents are set to zero before being
returned. Read moreSource§unsafe fn shrink(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, TargetAllocError>
unsafe fn shrink( &self, ptr: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, TargetAllocError>
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
allocate, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<A, S> BumpAllocator for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
impl<A, S> BumpAllocator for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Source§fn as_scope(&self) -> &BumpScope<'_, Self::Allocator, Self::Settings>
fn as_scope(&self) -> &BumpScope<'_, Self::Allocator, Self::Settings>
&BumpScope.Source§fn as_mut_scope(
&mut self,
) -> &mut BumpScope<'_, Self::Allocator, Self::Settings>
fn as_mut_scope( &mut self, ) -> &mut BumpScope<'_, Self::Allocator, Self::Settings>
&mut BumpScope.Source§fn scope_guard(&mut self) -> BumpScopeGuard<'_, Self::Allocator, Self::Settings>
fn scope_guard(&mut self) -> BumpScopeGuard<'_, Self::Allocator, Self::Settings>
BumpScopeGuard. Read moreSource§fn scoped<R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, Self::Allocator, Self::Settings>) -> R,
) -> R
fn scoped<R>( &mut self, f: impl FnOnce(&mut BumpScope<'_, Self::Allocator, Self::Settings>) -> R, ) -> R
f with a new child scope. Read moreSource§fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, Self::Allocator, <Self::Settings as BumpAllocatorSettings>::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
&mut self,
f: impl FnOnce(&mut BumpScope<'_, Self::Allocator, <Self::Settings as BumpAllocatorSettings>::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> Rwhere
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
f with a new child scope of a new minimum alignment. Read moreSource§impl<A, S> BumpAllocatorCore for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
impl<A, S> BumpAllocatorCore for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Source§fn any_stats(&self) -> AnyStats<'_>
fn any_stats(&self) -> AnyStats<'_>
Source§fn checkpoint(&self) -> Checkpoint
fn checkpoint(&self) -> Checkpoint
Source§unsafe fn reset_to(&self, checkpoint: Checkpoint)
unsafe fn reset_to(&self, checkpoint: Checkpoint)
Source§fn is_claimed(&self) -> bool
fn is_claimed(&self) -> bool
Source§fn prepare_allocation(
&self,
layout: Layout,
) -> Result<Range<NonNull<u8>>, AllocError>
fn prepare_allocation( &self, layout: Layout, ) -> Result<Range<NonNull<u8>>, AllocError>
layout.size(). Read moreSource§unsafe fn allocate_prepared(
&self,
layout: Layout,
range: Range<NonNull<u8>>,
) -> NonNull<u8>
unsafe fn allocate_prepared( &self, layout: Layout, range: Range<NonNull<u8>>, ) -> NonNull<u8>
prepare_allocation call. Read moreSource§fn prepare_allocation_rev(
&self,
layout: Layout,
) -> Result<Range<NonNull<u8>>, AllocError>
fn prepare_allocation_rev( &self, layout: Layout, ) -> Result<Range<NonNull<u8>>, AllocError>
layout.size(). Read moreSource§impl<A, S> BumpAllocatorTyped for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
impl<A, S> BumpAllocatorTyped for Bump<A, S>where
A: Allocator,
S: BumpAllocatorSettings,
Source§type TypedStats<'b> = Stats<'b, S>
where
Self: 'b
type TypedStats<'b> = Stats<'b, S> where Self: 'b
Source§fn typed_stats(&self) -> Self::TypedStats<'_>
fn typed_stats(&self) -> Self::TypedStats<'_>
Source§fn try_allocate_layout(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
fn try_allocate_layout(&self, layout: Layout) -> Result<NonNull<u8>, AllocError>
Source§fn try_allocate_sized<T>(&self) -> Result<NonNull<T>, AllocError>
fn try_allocate_sized<T>(&self) -> Result<NonNull<T>, AllocError>
Source§fn allocate_slice<T>(&self, len: usize) -> NonNull<T>
fn allocate_slice<T>(&self, len: usize) -> NonNull<T>
Source§fn try_allocate_slice<T>(&self, len: usize) -> Result<NonNull<T>, AllocError>
fn try_allocate_slice<T>(&self, len: usize) -> Result<NonNull<T>, AllocError>
Source§fn allocate_slice_for<T>(&self, slice: &[T]) -> NonNull<T>
fn allocate_slice_for<T>(&self, slice: &[T]) -> NonNull<T>
Source§fn try_allocate_slice_for<T>(
&self,
slice: &[T],
) -> Result<NonNull<T>, AllocError>
fn try_allocate_slice_for<T>( &self, slice: &[T], ) -> Result<NonNull<T>, AllocError>
Source§unsafe fn shrink_slice<T>(
&self,
ptr: NonNull<T>,
old_len: usize,
new_len: usize,
) -> Option<NonNull<T>>
unsafe fn shrink_slice<T>( &self, ptr: NonNull<T>, old_len: usize, new_len: usize, ) -> Option<NonNull<T>>
Source§fn prepare_slice_allocation<T>(&self, len: usize) -> NonNull<[T]>
fn prepare_slice_allocation<T>(&self, len: usize) -> NonNull<[T]>
prepare_allocation. Read moreSource§fn try_prepare_slice_allocation<T>(
&self,
len: usize,
) -> Result<NonNull<[T]>, AllocError>
fn try_prepare_slice_allocation<T>( &self, len: usize, ) -> Result<NonNull<[T]>, AllocError>
prepare_allocation. Read moreSource§unsafe fn allocate_prepared_slice<T>(
&self,
ptr: NonNull<T>,
len: usize,
cap: usize,
) -> NonNull<[T]>
unsafe fn allocate_prepared_slice<T>( &self, ptr: NonNull<T>, len: usize, cap: usize, ) -> NonNull<[T]>
allocate_prepared. Read moreSource§fn prepare_slice_allocation_rev<T>(&self, len: usize) -> (NonNull<T>, usize)
fn prepare_slice_allocation_rev<T>(&self, len: usize) -> (NonNull<T>, usize)
prepare_allocation_rev. Read moreSource§fn try_prepare_slice_allocation_rev<T>(
&self,
len: usize,
) -> Result<(NonNull<T>, usize), AllocError>
fn try_prepare_slice_allocation_rev<T>( &self, len: usize, ) -> Result<(NonNull<T>, usize), AllocError>
prepare_allocation_rev. Read moreSource§unsafe fn allocate_prepared_slice_rev<T>(
&self,
ptr: NonNull<T>,
len: usize,
cap: usize,
) -> NonNull<[T]>
unsafe fn allocate_prepared_slice_rev<T>( &self, ptr: NonNull<T>, len: usize, cap: usize, ) -> NonNull<[T]>
allocate_prepared_rev. Read moreSource§fn reserve(&self, additional: usize)
fn reserve(&self, additional: usize)
additional more bytes to be bump allocated.
The bump allocator may reserve more space to avoid frequent reallocations.
After calling reserve, self.stats().remaining() will be greater than or equal to
additional. Does nothing if the capacity is already sufficient. Read moreSource§fn try_reserve(&self, additional: usize) -> Result<(), AllocError>
fn try_reserve(&self, additional: usize) -> Result<(), AllocError>
additional more bytes to be bump allocated.
The bump allocator may reserve more space to avoid frequent reallocations.
After calling reserve, self.stats().remaining() will be greater than or equal to
additional. Does nothing if the capacity is already sufficient. Read more