macro_rules! forward_methods {
(
self: $self:ident
access: {$access:expr}
access_mut: {$access_mut:expr}
lifetime: $lifetime:lifetime
) => {
#[must_use]
#[inline(always)]
pub fn allocator(&$self) -> Option<&$lifetime A> {
BumpAllocatorScope::allocator($access)
}
#[inline(always)]
pub fn claim(&$self) -> BumpClaimGuard<'_, $lifetime, A, S> {
BumpAllocatorScope::claim($access)
}
#[must_use]
#[inline(always)]
pub fn is_claimed(&self) -> bool {
BumpAllocatorCore::is_claimed(self)
}
#[inline(always)]
pub fn scope_guard(&mut $self) -> BumpScopeGuard<'_, A, S> {
BumpAllocator::scope_guard($access_mut)
}
#[inline(always)]
pub fn scoped<R>(&mut $self, f: impl FnOnce(&mut BumpScope<A, S>) -> R) -> R {
BumpAllocator::scoped($access_mut, f)
}
#[inline(always)]
pub fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
&mut $self,
f: impl FnOnce(&mut BumpScope<A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> R
where
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
{
BumpAllocator::scoped_aligned($access_mut, f)
}
#[inline(always)]
pub fn aligned<const NEW_MIN_ALIGN: usize, R>(
&mut $self,
f: impl FnOnce(&mut BumpScope<$lifetime, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
) -> R
where
MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
{
BumpAllocatorScope::aligned($access_mut, f)
}
#[inline(always)]
pub fn checkpoint(&$self) -> Checkpoint {
BumpAllocatorCore::checkpoint($access)
}
#[inline(always)]
pub unsafe fn reset_to(&$self, checkpoint: Checkpoint) {
unsafe { BumpAllocatorCore::reset_to($access, checkpoint) }
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc<T>(&$self, value: T) -> BumpBox<$lifetime, T> {
BumpAllocatorTypedScope::alloc($access, value)
}
#[inline(always)]
pub fn try_alloc<T>(&$self, value: T) -> Result<BumpBox<$lifetime, T>, AllocError> {
BumpAllocatorTypedScope::try_alloc($access, value)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_with<T>(&$self, f: impl FnOnce() -> T) -> BumpBox<$lifetime, T> {
BumpAllocatorTypedScope::alloc_with($access, f)
}
#[inline(always)]
pub fn try_alloc_with<T>(&$self, f: impl FnOnce() -> T) -> Result<BumpBox<$lifetime, T>, AllocError> {
BumpAllocatorTypedScope::try_alloc_with($access, f)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_default<T: Default>(&$self) -> BumpBox<$lifetime, T> {
BumpAllocatorTypedScope::alloc_default($access)
}
#[inline(always)]
pub fn try_alloc_default<T: Default>(&$self) -> Result<BumpBox<$lifetime, T>, AllocError> {
BumpAllocatorTypedScope::try_alloc_default($access)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
#[cfg(feature = "nightly-clone-to-uninit")]
pub fn alloc_clone<T: CloneToUninit + ?Sized>(&$self, value: &T) -> BumpBox<$lifetime, T> {
BumpAllocatorTypedScope::alloc_clone($access, value)
}
#[inline(always)]
#[cfg(feature = "nightly-clone-to-uninit")]
pub fn try_alloc_clone<T: CloneToUninit + ?Sized>(&$self, value: &T) -> Result<BumpBox<$lifetime, T>, AllocError> {
BumpAllocatorTypedScope::try_alloc_clone($access, value)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_slice_move<T>(&$self, slice: impl OwnedSlice<Item = T>) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_slice_move($access, slice)
}
#[inline(always)]
pub fn try_alloc_slice_move<T>(&$self, slice: impl OwnedSlice<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_slice_move($access, slice)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_slice_copy<T: Copy>(&$self, slice: &[T]) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_slice_copy($access, slice)
}
#[inline(always)]
pub fn try_alloc_slice_copy<T: Copy>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_slice_copy($access, slice)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_slice_clone<T: Clone>(&$self, slice: &[T]) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_slice_clone($access, slice)
}
#[inline(always)]
pub fn try_alloc_slice_clone<T: Clone>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_slice_clone($access, slice)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_slice_fill<T: Clone>(&$self, len: usize, value: T) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_slice_fill($access, len, value)
}
#[inline(always)]
pub fn try_alloc_slice_fill<T: Clone>(&$self, len: usize, value: T) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_slice_fill($access, len, value)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_slice_fill_with<T>(&$self, len: usize, f: impl FnMut() -> T) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_slice_fill_with($access, len, f)
}
#[inline(always)]
pub fn try_alloc_slice_fill_with<T>(&$self, len: usize, f: impl FnMut() -> T) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_slice_fill_with($access, len, f)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_str(&$self, src: &str) -> BumpBox<$lifetime, str> {
BumpAllocatorTypedScope::alloc_str($access, src)
}
#[inline(always)]
pub fn try_alloc_str(&$self, src: &str) -> Result<BumpBox<$lifetime, str>, AllocError> {
BumpAllocatorTypedScope::try_alloc_str($access, src)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_fmt(&$self, args: fmt::Arguments) -> BumpBox<$lifetime, str> {
BumpAllocatorTypedScope::alloc_fmt($access, args)
}
#[inline(always)]
pub fn try_alloc_fmt(&$self, args: fmt::Arguments) -> Result<BumpBox<$lifetime, str>, AllocError> {
BumpAllocatorTypedScope::try_alloc_fmt($access, args)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_fmt_mut(&mut $self, args: fmt::Arguments) -> BumpBox<$lifetime, str> {
MutBumpAllocatorTypedScope::alloc_fmt_mut($access_mut, args)
}
#[inline(always)]
pub fn try_alloc_fmt_mut(&mut $self, args: fmt::Arguments) -> Result<BumpBox<$lifetime, str>, AllocError> {
MutBumpAllocatorTypedScope::try_alloc_fmt_mut($access_mut, args)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_cstr(&$self, src: &CStr) -> &$lifetime CStr {
BumpAllocatorTypedScope::alloc_cstr($access, src)
}
#[inline(always)]
pub fn try_alloc_cstr(&$self, src: &CStr) -> Result<&$lifetime CStr, AllocError> {
BumpAllocatorTypedScope::try_alloc_cstr($access, src)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_cstr_from_str(&$self, src: &str) -> &$lifetime CStr {
BumpAllocatorTypedScope::alloc_cstr_from_str($access, src)
}
#[inline(always)]
pub fn try_alloc_cstr_from_str(&$self, src: &str) -> Result<&$lifetime CStr, AllocError> {
BumpAllocatorTypedScope::try_alloc_cstr_from_str($access, src)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_cstr_fmt(&$self, args: fmt::Arguments) -> &$lifetime CStr {
BumpAllocatorTypedScope::alloc_cstr_fmt($access, args)
}
#[inline(always)]
pub fn try_alloc_cstr_fmt(&$self, args: fmt::Arguments) -> Result<&$lifetime CStr, AllocError> {
BumpAllocatorTypedScope::try_alloc_cstr_fmt($access, args)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_cstr_fmt_mut(&mut $self, args: fmt::Arguments) -> &$lifetime CStr {
MutBumpAllocatorTypedScope::alloc_cstr_fmt_mut($access_mut, args)
}
#[inline(always)]
pub fn try_alloc_cstr_fmt_mut(&mut $self, args: fmt::Arguments) -> Result<&$lifetime CStr, AllocError> {
MutBumpAllocatorTypedScope::try_alloc_cstr_fmt_mut($access_mut, args)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_iter<T>(&$self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
BumpAllocatorTypedScope::alloc_iter($access, iter)
}
#[inline(always)]
pub fn try_alloc_iter<T>(&$self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_iter($access, iter)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_iter_exact<T, I>(&$self, iter: impl IntoIterator<Item = T, IntoIter = I>) -> BumpBox<$lifetime, [T]>
where
I: ExactSizeIterator<Item = T>,
{
BumpAllocatorTypedScope::alloc_iter_exact($access, iter)
}
#[inline(always)]
pub fn try_alloc_iter_exact<T, I>(
&$self,
iter: impl IntoIterator<Item = T, IntoIter = I>,
) -> Result<BumpBox<$lifetime, [T]>, AllocError>
where
I: ExactSizeIterator<Item = T>,
{
BumpAllocatorTypedScope::try_alloc_iter_exact($access, iter)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_iter_mut<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
MutBumpAllocatorTypedScope::alloc_iter_mut($access_mut, iter)
}
#[inline(always)]
pub fn try_alloc_iter_mut<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
MutBumpAllocatorTypedScope::try_alloc_iter_mut($access_mut, iter)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_iter_mut_rev<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
MutBumpAllocatorTypedScope::alloc_iter_mut_rev($access_mut, iter)
}
#[inline(always)]
pub fn try_alloc_iter_mut_rev<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
MutBumpAllocatorTypedScope::try_alloc_iter_mut_rev($access_mut, iter)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_uninit<T>(&$self) -> BumpBox<$lifetime, MaybeUninit<T>> {
BumpAllocatorTypedScope::alloc_uninit($access)
}
#[inline(always)]
pub fn try_alloc_uninit<T>(&$self) -> Result<BumpBox<$lifetime, MaybeUninit<T>>, AllocError> {
BumpAllocatorTypedScope::try_alloc_uninit($access)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_uninit_slice<T>(&$self, len: usize) -> BumpBox<$lifetime, [MaybeUninit<T>]> {
BumpAllocatorTypedScope::alloc_uninit_slice($access, len)
}
#[inline(always)]
pub fn try_alloc_uninit_slice<T>(&$self, len: usize) -> Result<BumpBox<$lifetime, [MaybeUninit<T>]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_uninit_slice($access, len)
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn alloc_uninit_slice_for<T>(&$self, slice: &[T]) -> BumpBox<$lifetime, [MaybeUninit<T>]> {
BumpAllocatorTypedScope::alloc_uninit_slice_for($access, slice)
}
#[inline(always)]
pub fn try_alloc_uninit_slice_for<T>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [MaybeUninit<T>]>, AllocError> {
BumpAllocatorTypedScope::try_alloc_uninit_slice_for($access, slice)
}
#[inline(always)]
pub fn dealloc<T: ?Sized>(&$self, boxed: BumpBox<T>) {
BumpAllocatorTyped::dealloc($access, boxed);
}
#[inline(always)]
#[cfg(feature = "panic-on-alloc")]
pub fn reserve(&$self, additional: usize) {
BumpAllocatorTyped::reserve($access, additional);
}
#[inline(always)]
pub fn try_reserve(&$self, additional: usize) -> Result<(), AllocError> {
BumpAllocatorTyped::try_reserve($access, additional)
}
};
}
pub(crate) use forward_methods;