3 releases
new 0.0.3 | Oct 29, 2024 |
---|---|
0.0.2 | Sep 12, 2024 |
0.0.1 | Sep 6, 2024 |
#217 in Memory management
21 downloads per month
190KB
4.5K
SLoC
flex-alloc
This crate provides highly flexible container types (currently Box
, Cow
, and Vec
) which mimic the API provided in std
, with allocation flexibility going beyond what is supported by unstable features such as allocator-api
.
Both no-std
and no-alloc
environments are supported.
Highlights
- Optional
alloc
support, such that application may easily alternate between fixed buffers and heap allocation. - Custom allocator implementations, including the ability to spill from a small stack allocation to a heap allocation.
- Additional fallible update methods, allowing for more ergonomic fixed size collections and handling of allocation errors.
const
initializers.- Support for inline collections.
- Custom index types and growth behavior to manage memory usage.
Feature flags
-
The
std
flag (off by default) enables compatibility with thestd::error::Error
trait for error types, addsio::Write
support toVec
, and also enables thealloc
feature. -
With the
alloc
feature (on by default), access to the global allocator is enabled, and default constructors for allocated containers (such asVec::new
) are supported. -
The
allocator-api2
feature enables integration with theallocator-api2
crate, which offers support for theallocator-api
feature set on stable Rust. This can allow for allocators implementing the API to be passed toVec::new_in
. -
The
nightly
feature enables compatibility with the unstable Rustallocator-api
feature. This requires a nightly Rust compiler build. -
The
zeroize
feature enables integration with thezeroize
crate, including a zeroizing allocator. This can be used to automatically zero out allocated memory for allocated types, including the intermediate buffers produced during resizing in the case ofVec
.
Credits
This crate is partly inspired by coca, which has generally broader functionality, but currently only supports fixed-size containers. Portions are adapted from the Rust standard library.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~105KB