silly_alloc/lib.rs
1#![no_std]
2
3/*!
4`silly_alloc` is a collection of very basic allocators that are fast and small. Written with WebAssembly in mind.
5
6# Features
7
8- Bump allocators — Fast and small allocators that cannot free memory.
9- Bucket allocators — Alloctors that excel at frequent allocations and deallocations of a similar size.
10- Works with `#![no_std]`
11- Support for and tests on `wasm32-unknown-unknown` and `wasm32-wasi`.
12
13# Warning
14
15This crate is young and experimental. I have tried my best to ensure correct functionality through testing, but it’s very likely that there are bugs. It’s even more likely that features are missing that should be there. Please feel free to open issues or even PRs!
16
17# Examples
18
19- [Examples for bump allocators](bump/index.html)
20- [Examples for bucket allocators](bucket/index.html)
21
22# Running the tests
23
24To run the unit and integration tests:
25
26```shell
27$ cargo test --target=wasm32-wasi
28```
29
30To run the doc tests, Nightly Rust is required (as cross-compiling doc tests is still experimental) and a special environment variable needs to be set so that the macro crate generates the correct absolute paths for the bucket allocator types.
31
32```shell
33$ SILLY_ALLOC_DOC_TESTS=1 cargo +nightly test --doc --target wasm32-wasi -Zdoctest-xcompile
34```
35
36---
37License Apache 2.*/
38
39pub mod bump;
40pub use bump::BumpAllocator;
41pub use bump::SliceBumpAllocator;
42#[cfg(target_arch = "wasm32")]
43pub use bump::WasmBumpAllocator;
44
45pub mod bucket;
46
47pub use silly_alloc_macros::bucket_allocator;
48
49// Enable std for testing
50#[cfg(test)]
51#[macro_use]
52extern crate std;