static-alloc 0.0.1

General purpose global allocator(s) with static storage
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#![cfg_attr(feature = "try_reserve", feature(try_reserve))]

use static_alloc::Slab;

#[global_allocator]
static A: Slab<[u8; 1 << 16]> = unsafe {
    Slab::new([0; 1 << 16])
};

#[cfg(feature = "try_reserve")]
#[test]
fn vec_fail_reserve() {
    let mut v: Vec<u8> = Vec::new();
    assert!(v.try_reserve((1 << 16) + 1).is_err());
}