| 1 |
# allocator-api2 |
| 2 |
|
| 3 |
[](https://crates.io/crates/allocator-api2) |
| 4 |
[](https://docs.rs/allocator-api2) |
| 5 |
[](https://github.com/zakarumych/allocator-api2/actions/workflows/badge.yml) |
| 6 |
[](COPYING) |
| 7 |
 |
| 8 |
|
| 9 |
This crate mirrors types and traits from Rust's unstable [`allocator_api`] |
| 10 |
The intention of this crate is to serve as substitution for actual thing |
| 11 |
for libs when build on stable and beta channels. |
| 12 |
The target users are library authors who implement allocators or collection types |
| 13 |
that use allocators, or anyone else who wants using [`allocator_api`] |
| 14 |
|
| 15 |
The crate should be frequently updated with minor version bump. |
| 16 |
When [`allocator_api`] is stable this crate will get version `1.0` and simply |
| 17 |
re-export from `core`, `alloc` and `std`. |
| 18 |
|
| 19 |
The code is mostly verbatim copy from rust repository. |
| 20 |
Mostly attributes are removed. |
| 21 |
|
| 22 |
## Usage |
| 23 |
|
| 24 |
This paragraph describes how to use this crate correctly to ensure |
| 25 |
compatibility and interoperability on both stable and nightly channels. |
| 26 |
|
| 27 |
If you are writing a library that interacts with allocators API, you can |
| 28 |
add this crate as a dependency and use the types and traits from this |
| 29 |
crate instead of the ones in `core` or `alloc`. |
| 30 |
This will allow your library to compile on stable and beta channels. |
| 31 |
|
| 32 |
Your library *MAY* provide a feature that will enable "allocator-api2/nightly". |
| 33 |
When this feature is enabled, your library *MUST* enable |
| 34 |
unstable `#![feature(allocator_api)]` or it may not compile. |
| 35 |
If feature is not provided, your library may not be compatible with the |
| 36 |
rest of the users and cause compilation errors on nightly channel |
| 37 |
when some other crate enables "allocator-api2/nightly" feature. |
| 38 |
|
| 39 |
# Minimal Supported Rust Version (MSRV) |
| 40 |
|
| 41 |
This crate is guaranteed to compile on stable Rust 1.63 and up. |
| 42 |
A feature "fresh-rust" bumps the MSRV to unspecified higher version, but should be compatible with |
| 43 |
at least few latest stable releases. The feature enables some additional functionality: |
| 44 |
|
| 45 |
* `CStr` without "std" feature |
| 46 |
|
| 47 |
## License |
| 48 |
|
| 49 |
Licensed under either of |
| 50 |
|
| 51 |
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 52 |
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 53 |
|
| 54 |
at your option. |
| 55 |
|
| 56 |
## Contributions |
| 57 |
|
| 58 |
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
| 59 |
|
| 60 |
|
| 61 |
[`allocator_api`]: https://doc.rust-lang.org/unstable-book/library-features/allocator-api.html |