Skip to content

Commit

Permalink
Add support for custom allocators by the allocator-api2 crate.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tage Johansson committed Nov 15, 2024
1 parent 5a1457d commit 06dd7a5
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 50 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ readme = "README.md"
exclude = ["/.travis.yml", "/deploy-docs.sh"]

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

[dependencies]
allocator-api2 = "0.2.20"
serde = { version = "1.0", features = [ "derive" ], optional = true }
Loading

0 comments on commit 06dd7a5

Please sign in to comment.