pub struct Stack { /* private fields */ }Expand description
Single heap allocation, aligned to 16 bytes, with a 64-byte painted lower guard. This detects damage at boundaries; it does not provide memory protection.
Implementations§
Source§impl Stack
impl Stack
Sourcepub fn new(size: usize) -> Self
pub fn new(size: usize) -> Self
Allocate a stack with at least DEFAULT_MIN_STACK_SIZE (4 KiB) usable bytes,
rounded up to 16 bytes, plus a 64-byte painted lower guard.
Sourcepub fn with_min_size(size: usize, min_usable: usize) -> Self
pub fn with_min_size(size: usize, min_usable: usize) -> Self
Allocate a stack with a caller-chosen minimum usable size, floored at
MIN_STACK_SIZE (2 KiB), rounded up to 16 bytes, plus the same 64-byte
painted lower guard as Stack::new.
Lowering the minimum below 4 KiB saves RAM on constrained MCUs (e.g. 256 KiB SRAM), at the cost of tighter headroom for call depth, debug frames, suspended futures pinned on the native stack, and shared interrupt frames. Audit worst-case stack usage before choosing a 2 KiB stack.
Sourcepub fn try_with_min_size(size: usize, min_usable: usize) -> Option<Self>
pub fn try_with_min_size(size: usize, min_usable: usize) -> Option<Self>
Like Stack::with_min_size, but returns None instead of panicking or
aborting when the size is unrepresentable or the allocator is out of memory.