bump_scope/
bump_align_guard.rs1use crate::{BumpScope, align_pos, settings::BumpAllocatorSettings};
2
3pub(crate) struct BumpAlignGuard<'b, 'a, A, S>
9where
10 S: BumpAllocatorSettings,
11{
12 pub(crate) scope: &'b mut BumpScope<'a, A, S>,
13}
14
15impl<A, S> Drop for BumpAlignGuard<'_, '_, A, S>
16where
17 S: BumpAllocatorSettings,
18{
19 #[inline(always)]
20 fn drop(&mut self) {
21 if let Some(chunk) = self.scope.raw.chunk.get().as_non_dummy() {
22 let pos = chunk.pos().addr().get();
23 let addr = align_pos(S::UP, S::MIN_ALIGN, pos);
24 unsafe { chunk.set_pos_addr(addr) };
25 }
26 }
27}
28
29impl<'b, 'a, A, S> BumpAlignGuard<'b, 'a, A, S>
30where
31 S: BumpAllocatorSettings,
32{
33 #[inline(always)]
34 pub(crate) fn new(scope: &'b mut BumpScope<'a, A, S>) -> Self {
35 Self { scope }
36 }
37}