stack_arena/
lib.rs

1mod error;
2mod simple_obstack;
3mod stack_arena;
4mod traits;
5
6pub use error::AllocError;
7pub use simple_obstack::SimpleObstack;
8pub use stack_arena::StackArena;
9pub use traits::Allocator;
10
11#[cfg(test)]
12mod tests {
13    use crate::StackArena;
14
15    #[test]
16    fn test_obstack() {
17        let mut stack = StackArena::new();
18        stack.extend("hello");
19        stack.extend(" ");
20        stack.extend("world!");
21        let result = unsafe { stack.finish().as_ref() };
22        let expected = b"hello world!";
23        assert_eq!(result, expected);
24    }
25}