1macro_rules! forward_methods {
9 (
10 self: $self:ident
11 access: {$access:expr}
12 access_mut: {$access_mut:expr}
13 lifetime: $lifetime:lifetime
14 ) => {
15 #[inline(always)]
17 pub fn claim(&$self) -> BumpClaimGuard<'_, $lifetime, A, S> {
18 BumpAllocatorScope::claim($access)
19 }
20
21 #[must_use]
23 #[inline(always)]
24 pub fn is_claimed(&self) -> bool {
25 BumpAllocatorCore::is_claimed(self)
26 }
27
28 #[inline(always)]
30 pub fn scope_guard(&mut $self) -> BumpScopeGuard<'_, A, S> {
31 BumpAllocator::scope_guard($access_mut)
32 }
33
34 #[inline(always)]
36 pub fn scoped<R>(&mut $self, f: impl FnOnce(&mut BumpScope<A, S>) -> R) -> R {
37 BumpAllocator::scoped($access_mut, f)
38 }
39
40 #[inline(always)]
42 pub fn scoped_aligned<const NEW_MIN_ALIGN: usize, R>(
43 &mut $self,
44 f: impl FnOnce(&mut BumpScope<A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
45 ) -> R
46 where
47 MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
48 {
49 BumpAllocator::scoped_aligned($access_mut, f)
50 }
51
52 #[inline(always)]
54 pub fn aligned<const NEW_MIN_ALIGN: usize, R>(
55 &mut $self,
56 f: impl FnOnce(&mut BumpScope<$lifetime, A, S::WithMinimumAlignment<NEW_MIN_ALIGN>>) -> R,
57 ) -> R
58 where
59 MinimumAlignment<NEW_MIN_ALIGN>: SupportedMinimumAlignment,
60 {
61 BumpAllocatorScope::aligned($access_mut, f)
62 }
63
64 #[inline(always)]
66 pub fn checkpoint(&$self) -> Checkpoint {
67 BumpAllocatorCore::checkpoint($access)
68 }
69
70 #[inline(always)]
72 pub unsafe fn reset_to(&$self, checkpoint: Checkpoint) {
73 unsafe { BumpAllocatorCore::reset_to($access, checkpoint) }
74 }
75
76 #[inline(always)]
78 #[cfg(feature = "panic-on-alloc")]
79 pub fn alloc<T>(&$self, value: T) -> BumpBox<$lifetime, T> {
80 BumpAllocatorTypedScope::alloc($access, value)
81 }
82
83 #[inline(always)]
85 pub fn try_alloc<T>(&$self, value: T) -> Result<BumpBox<$lifetime, T>, AllocError> {
86 BumpAllocatorTypedScope::try_alloc($access, value)
87 }
88
89 #[inline(always)]
91 #[cfg(feature = "panic-on-alloc")]
92 pub fn alloc_with<T>(&$self, f: impl FnOnce() -> T) -> BumpBox<$lifetime, T> {
93 BumpAllocatorTypedScope::alloc_with($access, f)
94 }
95
96 #[inline(always)]
98 pub fn try_alloc_with<T>(&$self, f: impl FnOnce() -> T) -> Result<BumpBox<$lifetime, T>, AllocError> {
99 BumpAllocatorTypedScope::try_alloc_with($access, f)
100 }
101
102 #[inline(always)]
104 #[cfg(feature = "panic-on-alloc")]
105 pub fn alloc_default<T: Default>(&$self) -> BumpBox<$lifetime, T> {
106 BumpAllocatorTypedScope::alloc_default($access)
107 }
108
109 #[inline(always)]
111 pub fn try_alloc_default<T: Default>(&$self) -> Result<BumpBox<$lifetime, T>, AllocError> {
112 BumpAllocatorTypedScope::try_alloc_default($access)
113 }
114
115 #[inline(always)]
117 #[cfg(feature = "nightly-clone-to-uninit")]
118 pub fn alloc_clone<T: CloneToUninit + ?Sized>(&$self, value: &T) -> BumpBox<$lifetime, T> {
119 BumpAllocatorTypedScope::alloc_clone($access, value)
120 }
121
122 #[inline(always)]
124 #[cfg(feature = "nightly-clone-to-uninit")]
125 pub fn try_alloc_clone<T: CloneToUninit + ?Sized>(&$self, value: &T) -> Result<BumpBox<$lifetime, T>, AllocError> {
126 BumpAllocatorTypedScope::try_alloc_clone($access, value)
127 }
128
129 #[inline(always)]
131 #[cfg(feature = "panic-on-alloc")]
132 pub fn alloc_slice_move<T>(&$self, slice: impl OwnedSlice<Item = T>) -> BumpBox<$lifetime, [T]> {
133 BumpAllocatorTypedScope::alloc_slice_move($access, slice)
134 }
135
136 #[inline(always)]
138 pub fn try_alloc_slice_move<T>(&$self, slice: impl OwnedSlice<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
139 BumpAllocatorTypedScope::try_alloc_slice_move($access, slice)
140 }
141
142 #[inline(always)]
144 #[cfg(feature = "panic-on-alloc")]
145 pub fn alloc_slice_copy<T: Copy>(&$self, slice: &[T]) -> BumpBox<$lifetime, [T]> {
146 BumpAllocatorTypedScope::alloc_slice_copy($access, slice)
147 }
148
149 #[inline(always)]
151 pub fn try_alloc_slice_copy<T: Copy>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
152 BumpAllocatorTypedScope::try_alloc_slice_copy($access, slice)
153 }
154
155 #[inline(always)]
157 #[cfg(feature = "panic-on-alloc")]
158 pub fn alloc_slice_clone<T: Clone>(&$self, slice: &[T]) -> BumpBox<$lifetime, [T]> {
159 BumpAllocatorTypedScope::alloc_slice_clone($access, slice)
160 }
161
162 #[inline(always)]
164 pub fn try_alloc_slice_clone<T: Clone>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
165 BumpAllocatorTypedScope::try_alloc_slice_clone($access, slice)
166 }
167
168 #[inline(always)]
170 #[cfg(feature = "panic-on-alloc")]
171 pub fn alloc_slice_fill<T: Clone>(&$self, len: usize, value: T) -> BumpBox<$lifetime, [T]> {
172 BumpAllocatorTypedScope::alloc_slice_fill($access, len, value)
173 }
174
175 #[inline(always)]
177 pub fn try_alloc_slice_fill<T: Clone>(&$self, len: usize, value: T) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
178 BumpAllocatorTypedScope::try_alloc_slice_fill($access, len, value)
179 }
180
181 #[inline(always)]
183 #[cfg(feature = "panic-on-alloc")]
184 pub fn alloc_slice_fill_with<T>(&$self, len: usize, f: impl FnMut() -> T) -> BumpBox<$lifetime, [T]> {
185 BumpAllocatorTypedScope::alloc_slice_fill_with($access, len, f)
186 }
187
188 #[inline(always)]
190 pub fn try_alloc_slice_fill_with<T>(&$self, len: usize, f: impl FnMut() -> T) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
191 BumpAllocatorTypedScope::try_alloc_slice_fill_with($access, len, f)
192 }
193
194 #[inline(always)]
196 #[cfg(feature = "panic-on-alloc")]
197 pub fn alloc_str(&$self, src: &str) -> BumpBox<$lifetime, str> {
198 BumpAllocatorTypedScope::alloc_str($access, src)
199 }
200
201 #[inline(always)]
203 pub fn try_alloc_str(&$self, src: &str) -> Result<BumpBox<$lifetime, str>, AllocError> {
204 BumpAllocatorTypedScope::try_alloc_str($access, src)
205 }
206
207 #[inline(always)]
209 #[cfg(feature = "panic-on-alloc")]
210 pub fn alloc_fmt(&$self, args: fmt::Arguments) -> BumpBox<$lifetime, str> {
211 BumpAllocatorTypedScope::alloc_fmt($access, args)
212 }
213
214 #[inline(always)]
216 pub fn try_alloc_fmt(&$self, args: fmt::Arguments) -> Result<BumpBox<$lifetime, str>, AllocError> {
217 BumpAllocatorTypedScope::try_alloc_fmt($access, args)
218 }
219
220 #[inline(always)]
222 #[cfg(feature = "panic-on-alloc")]
223 pub fn alloc_fmt_mut(&mut $self, args: fmt::Arguments) -> BumpBox<$lifetime, str> {
224 MutBumpAllocatorTypedScope::alloc_fmt_mut($access_mut, args)
225 }
226
227 #[inline(always)]
229 pub fn try_alloc_fmt_mut(&mut $self, args: fmt::Arguments) -> Result<BumpBox<$lifetime, str>, AllocError> {
230 MutBumpAllocatorTypedScope::try_alloc_fmt_mut($access_mut, args)
231 }
232
233 #[inline(always)]
235 #[cfg(feature = "panic-on-alloc")]
236 pub fn alloc_cstr(&$self, src: &CStr) -> &$lifetime CStr {
237 BumpAllocatorTypedScope::alloc_cstr($access, src)
238 }
239
240 #[inline(always)]
242 pub fn try_alloc_cstr(&$self, src: &CStr) -> Result<&$lifetime CStr, AllocError> {
243 BumpAllocatorTypedScope::try_alloc_cstr($access, src)
244 }
245
246 #[inline(always)]
248 #[cfg(feature = "panic-on-alloc")]
249 pub fn alloc_cstr_from_str(&$self, src: &str) -> &$lifetime CStr {
250 BumpAllocatorTypedScope::alloc_cstr_from_str($access, src)
251 }
252
253 #[inline(always)]
255 pub fn try_alloc_cstr_from_str(&$self, src: &str) -> Result<&$lifetime CStr, AllocError> {
256 BumpAllocatorTypedScope::try_alloc_cstr_from_str($access, src)
257 }
258
259 #[inline(always)]
261 #[cfg(feature = "panic-on-alloc")]
262 pub fn alloc_cstr_fmt(&$self, args: fmt::Arguments) -> &$lifetime CStr {
263 BumpAllocatorTypedScope::alloc_cstr_fmt($access, args)
264 }
265
266 #[inline(always)]
268 pub fn try_alloc_cstr_fmt(&$self, args: fmt::Arguments) -> Result<&$lifetime CStr, AllocError> {
269 BumpAllocatorTypedScope::try_alloc_cstr_fmt($access, args)
270 }
271
272 #[inline(always)]
274 #[cfg(feature = "panic-on-alloc")]
275 pub fn alloc_cstr_fmt_mut(&mut $self, args: fmt::Arguments) -> &$lifetime CStr {
276 MutBumpAllocatorTypedScope::alloc_cstr_fmt_mut($access_mut, args)
277 }
278
279 #[inline(always)]
281 pub fn try_alloc_cstr_fmt_mut(&mut $self, args: fmt::Arguments) -> Result<&$lifetime CStr, AllocError> {
282 MutBumpAllocatorTypedScope::try_alloc_cstr_fmt_mut($access_mut, args)
283 }
284
285 #[inline(always)]
287 #[cfg(feature = "panic-on-alloc")]
288 pub fn alloc_iter<T>(&$self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
289 BumpAllocatorTypedScope::alloc_iter($access, iter)
290 }
291
292 #[inline(always)]
294 pub fn try_alloc_iter<T>(&$self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
295 BumpAllocatorTypedScope::try_alloc_iter($access, iter)
296 }
297
298 #[inline(always)]
300 #[cfg(feature = "panic-on-alloc")]
301 pub fn alloc_iter_exact<T, I>(&$self, iter: impl IntoIterator<Item = T, IntoIter = I>) -> BumpBox<$lifetime, [T]>
302 where
303 I: ExactSizeIterator<Item = T>,
304 {
305 BumpAllocatorTypedScope::alloc_iter_exact($access, iter)
306 }
307
308 #[inline(always)]
310 pub fn try_alloc_iter_exact<T, I>(
311 &$self,
312 iter: impl IntoIterator<Item = T, IntoIter = I>,
313 ) -> Result<BumpBox<$lifetime, [T]>, AllocError>
314 where
315 I: ExactSizeIterator<Item = T>,
316 {
317 BumpAllocatorTypedScope::try_alloc_iter_exact($access, iter)
318 }
319
320 #[inline(always)]
322 #[cfg(feature = "panic-on-alloc")]
323 pub fn alloc_iter_mut<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
324 MutBumpAllocatorTypedScope::alloc_iter_mut($access_mut, iter)
325 }
326
327 #[inline(always)]
329 pub fn try_alloc_iter_mut<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
330 MutBumpAllocatorTypedScope::try_alloc_iter_mut($access_mut, iter)
331 }
332
333 #[inline(always)]
335 #[cfg(feature = "panic-on-alloc")]
336 pub fn alloc_iter_mut_rev<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> BumpBox<$lifetime, [T]> {
337 MutBumpAllocatorTypedScope::alloc_iter_mut_rev($access_mut, iter)
338 }
339
340 #[inline(always)]
342 pub fn try_alloc_iter_mut_rev<T>(&mut $self, iter: impl IntoIterator<Item = T>) -> Result<BumpBox<$lifetime, [T]>, AllocError> {
343 MutBumpAllocatorTypedScope::try_alloc_iter_mut_rev($access_mut, iter)
344 }
345
346 #[inline(always)]
348 #[cfg(feature = "panic-on-alloc")]
349 pub fn alloc_uninit<T>(&$self) -> BumpBox<$lifetime, MaybeUninit<T>> {
350 BumpAllocatorTypedScope::alloc_uninit($access)
351 }
352
353 #[inline(always)]
355 pub fn try_alloc_uninit<T>(&$self) -> Result<BumpBox<$lifetime, MaybeUninit<T>>, AllocError> {
356 BumpAllocatorTypedScope::try_alloc_uninit($access)
357 }
358
359 #[inline(always)]
361 #[cfg(feature = "panic-on-alloc")]
362 pub fn alloc_uninit_slice<T>(&$self, len: usize) -> BumpBox<$lifetime, [MaybeUninit<T>]> {
363 BumpAllocatorTypedScope::alloc_uninit_slice($access, len)
364 }
365
366 #[inline(always)]
368 pub fn try_alloc_uninit_slice<T>(&$self, len: usize) -> Result<BumpBox<$lifetime, [MaybeUninit<T>]>, AllocError> {
369 BumpAllocatorTypedScope::try_alloc_uninit_slice($access, len)
370 }
371
372 #[inline(always)]
374 #[cfg(feature = "panic-on-alloc")]
375 pub fn alloc_uninit_slice_for<T>(&$self, slice: &[T]) -> BumpBox<$lifetime, [MaybeUninit<T>]> {
376 BumpAllocatorTypedScope::alloc_uninit_slice_for($access, slice)
377 }
378
379 #[inline(always)]
381 pub fn try_alloc_uninit_slice_for<T>(&$self, slice: &[T]) -> Result<BumpBox<$lifetime, [MaybeUninit<T>]>, AllocError> {
382 BumpAllocatorTypedScope::try_alloc_uninit_slice_for($access, slice)
383 }
384
385 #[inline(always)]
387 pub fn dealloc<T: ?Sized>(&$self, boxed: BumpBox<T>) {
388 BumpAllocatorTyped::dealloc($access, boxed);
389 }
390
391 #[inline(always)]
393 #[cfg(feature = "panic-on-alloc")]
394 pub fn reserve(&$self, additional: usize) {
395 BumpAllocatorTyped::reserve($access, additional);
396 }
397
398 #[inline(always)]
400 pub fn try_reserve(&$self, additional: usize) -> Result<(), AllocError> {
401 BumpAllocatorTyped::try_reserve($access, additional)
402 }
403 };
404}
405
406pub(crate) use forward_methods;