1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Scoped frame guards.
use crateMkAllocator;
/// A guard that represents a frame scope.
///
/// When dropped, the frame arena is reset to its state when the guard was created.
/// This is useful for sub-frame temporary allocations.
///
/// # Example
///
/// ```rust,ignore
/// let alloc = MkAllocator::with_defaults();
/// alloc.begin_frame();
///
/// {
/// let _scope = alloc.scope();
/// let temp = alloc.frame_alloc::<[u8; 1024]>();
/// // temp is valid here
/// } // temp is invalidated, memory reclaimed
///
/// // Can allocate more in the same frame
/// let other = alloc.frame_alloc::<u32>();
///
/// alloc.end_frame();
/// ```