Skip to main content

bump_scope/traits/
mut_bump_allocator_core.rs

1use crate::{
2    BaseAllocator, Bump, BumpScope, WithoutDealloc, WithoutShrink,
3    settings::BumpAllocatorSettings,
4    traits::{BumpAllocatorCore, assert_implements},
5};
6
7/// A mutable bump allocator.
8///
9/// # Safety
10///
11/// Implementors must have exclusive access to to the bump allocator.
12pub unsafe trait MutBumpAllocatorCore: BumpAllocatorCore {}
13
14assert_implements! {
15    [MutBumpAllocatorCore + ?Sized]
16
17    Bump
18    &mut Bump
19
20    BumpScope
21    &mut BumpScope
22
23    dyn MutBumpAllocatorCore
24    &mut dyn MutBumpAllocatorCore
25}
26
27unsafe impl<A: MutBumpAllocatorCore + ?Sized> MutBumpAllocatorCore for &mut A {}
28
29unsafe impl<A: MutBumpAllocatorCore> MutBumpAllocatorCore for WithoutDealloc<A> {}
30unsafe impl<A: MutBumpAllocatorCore> MutBumpAllocatorCore for WithoutShrink<A> {}
31
32unsafe impl<A, S> MutBumpAllocatorCore for Bump<A, S>
33where
34    A: BaseAllocator<S::GuaranteedAllocated>,
35    S: BumpAllocatorSettings,
36{
37}
38
39unsafe impl<A, S> MutBumpAllocatorCore for BumpScope<'_, A, S>
40where
41    A: BaseAllocator<S::GuaranteedAllocated>,
42    S: BumpAllocatorSettings,
43{
44}