Skip to content

Commit 06dd7a5

Browse files
author
Tage Johansson
committed
Add support for custom allocators by the allocator-api2 crate.
This commit adds allocator-api2 (a drop-in replacement for the `Allocator` trait on stable) as a dependency. The underlying `Vec` is replaced by `allocator_api2::vec::Vec`, and the type signiture of `VecMap<T>` is changed to `VecMap<T, A: Allocator = Global>`. It adds the methods `new_in()` and `with_capacity_in()` which creates a `VecMap` with a custom allocator. The old `new()` and `with_capacity()` methods are not removed and defaults to the default global allocator. I think that this commit is backwards compatable.
1 parent 5a1457d commit 06dd7a5

File tree

2 files changed

+88
-50
lines changed

2 files changed

+88
-50
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ readme = "README.md"
3939
exclude = ["/.travis.yml", "/deploy-docs.sh"]
4040

4141
[features]
42+
serde = ["dep:serde", "allocator-api2/serde"]
4243
# This feature is kept for backwards compatibility. Use feature "serde" instead.
4344
eders = [ "serde" ]
4445

4546
[dependencies]
47+
allocator-api2 = "0.2.20"
4648
serde = { version = "1.0", features = [ "derive" ], optional = true }

0 commit comments

Comments
 (0)