bump-into
A no_std
bump allocator sourcing space from a user-provided mutable
slice rather than from a global allocator, making it suitable for use
in embedded applications and tight loops.
Example
use ;
// allocate 64 bytes of uninitialized space on the stack
let mut bump_into_space = space_uninit!;
let bump_into = from_slice;
// allocating an object produces a mutable reference with
// a lifetime borrowed from `bump_into_space`, or gives
// back its argument in `Err` if there isn't enough space
let number: &mut u64 = bump_into
.alloc_with
.ok
.expect;
assert_eq!;
*number = 50000;
assert_eq!;
// slices can be allocated as well
let slice: &mut = bump_into
.alloc_n_with
.expect;
assert_eq!;
slice = 100;
assert_eq!;
Copying
Copyright (c) 2020 autumnontape
This project may be reproduced under the terms of the MIT or the Apache 2.0 license, at your option. A copy of each license is included.