Skip to main content

bump_scope/traits/
mut_bump_allocator_core.rs

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