Skip to main content

bump_scope/
traits.rs

1mod bump_allocator;
2mod bump_allocator_core;
3mod bump_allocator_core_scope;
4mod bump_allocator_scope;
5pub(crate) mod bump_allocator_typed;
6pub(crate) mod bump_allocator_typed_scope;
7mod macros;
8mod mut_bump_allocator_core;
9mod mut_bump_allocator_core_scope;
10pub(crate) mod mut_bump_allocator_typed;
11pub(crate) mod mut_bump_allocator_typed_scope;
12
13pub use bump_allocator::BumpAllocator;
14pub use bump_allocator_core::BumpAllocatorCore;
15pub use bump_allocator_core_scope::BumpAllocatorCoreScope;
16pub use bump_allocator_scope::BumpAllocatorScope;
17pub use bump_allocator_typed::BumpAllocatorTyped;
18pub use bump_allocator_typed_scope::BumpAllocatorTypedScope;
19pub(crate) use macros::forward_methods;
20pub use mut_bump_allocator_core::MutBumpAllocatorCore;
21pub use mut_bump_allocator_core_scope::MutBumpAllocatorCoreScope;
22pub use mut_bump_allocator_typed::MutBumpAllocatorTyped;
23pub use mut_bump_allocator_typed_scope::MutBumpAllocatorTypedScope;
24
25macro_rules! assert_dyn_compatible {
26    ($($tt:tt)*) => {
27        const _: () = {
28            #[expect(dead_code)]
29            fn assert_dyn_compatible(_: &dyn $($tt)*) {}
30        };
31    };
32}
33
34pub(crate) use assert_dyn_compatible;
35
36macro_rules! assert_implements {
37    ([$($what:tt)*] $($ty:ty)*) => {
38        #[cfg(test)]
39        const _: () = {
40            #[expect(unused_imports)]
41            use crate::{
42                alloc::Allocator,
43                traits::{
44                    BumpAllocatorCoreScope,
45                    MutBumpAllocatorCore,
46                    MutBumpAllocatorCoreScope,
47                }
48            };
49
50            #[allow(dead_code)]
51            type A = crate::alloc::NoopAllocator;
52            #[allow(dead_code)]
53            type Bump = crate::Bump<A>;
54            #[allow(dead_code)]
55            type BumpScope<'a> = crate::BumpScope<'a, A>;
56            #[allow(clippy::extra_unused_lifetimes)]
57            const fn implements<'a, What: $($what)*>() {}
58            $(
59                #[allow(clippy::mut_mut)]
60                implements::<$ty>();
61            )*
62        };
63    };
64}
65
66pub(crate) use assert_implements;
67
68assert_implements! {
69    [Allocator + ?Sized]
70
71    Bump
72    &Bump
73    &&Bump
74    &mut Bump
75    &mut &mut Bump
76
77    BumpScope
78    &BumpScope
79    &&BumpScope
80    &mut BumpScope
81    &mut &mut BumpScope
82}