Skip to content

Conversation

@tage64
Copy link

@tage64 tage64 commented Nov 15, 2024

Due to the disclaimer about new contributions in the README, you might think this PR is too much.
However, I needed it for my use case and thought that I can at least share it and then it is up to
you (the maintainer) to decide what to do with it.

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.

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.
@pczarn
Copy link
Contributor

pczarn commented Nov 17, 2024

Hey. That's ok. I will try to pick up maintenance sometime like I did for bit-vec

@pczarn
Copy link
Contributor

pczarn commented Nov 29, 2024

Huh, have I pushed into your master?

@pczarn
Copy link
Contributor

pczarn commented Nov 29, 2024

Looks good. Thanks

@pczarn pczarn merged commit 0d96598 into contain-rs:master Nov 29, 2024
5 checks passed
}
}

impl<V: PartialEq> PartialEq for VecMap<V> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the story for comparison with regard to allocators?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at the Vec in the standard library, it seems as that PartialEq and PartialOrd can be implemented for different allocators. I tried and it works so I will make a new pr with these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants