-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tracking Issue for BTreeSet
entry APIs
#133549
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
…-Simulacrum Add `BTreeSet` entry APIs to match `HashSet` The following methods are added, along with the corresponding `Entry` implementation. ```rust impl<T, A: Allocator + Clone> BTreeSet<T, A> { pub fn get_or_insert(&mut self, value: T) -> &T where T: Ord, {...} pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T where T: Borrow<Q> + Ord, Q: Ord, F: FnOnce(&Q) -> T, {...} pub fn entry(&mut self, value: T) -> Entry<'_, T, A> where T: Ord, {...} } ``` Tracking issue rust-lang#133549 Closes rust-lang/rfcs#1490
Rollup merge of rust-lang#133548 - cuviper:btreeset-entry-api, r=Mark-Simulacrum Add `BTreeSet` entry APIs to match `HashSet` The following methods are added, along with the corresponding `Entry` implementation. ```rust impl<T, A: Allocator + Clone> BTreeSet<T, A> { pub fn get_or_insert(&mut self, value: T) -> &T where T: Ord, {...} pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T where T: Borrow<Q> + Ord, Q: Ord, F: FnOnce(&Q) -> T, {...} pub fn entry(&mut self, value: T) -> Entry<'_, T, A> where T: Ord, {...} } ``` Tracking issue rust-lang#133549 Closes rust-lang/rfcs#1490
…-Simulacrum Add `BTreeSet` entry APIs to match `HashSet` The following methods are added, along with the corresponding `Entry` implementation. ```rust impl<T, A: Allocator + Clone> BTreeSet<T, A> { pub fn get_or_insert(&mut self, value: T) -> &T where T: Ord, {...} pub fn get_or_insert_with<Q: ?Sized, F>(&mut self, value: &Q, f: F) -> &T where T: Borrow<Q> + Ord, Q: Ord, F: FnOnce(&Q) -> T, {...} pub fn entry(&mut self, value: T) -> Entry<'_, T, A> where T: Ord, {...} } ``` Tracking issue rust-lang#133549 Closes rust-lang/rfcs#1490
I have a fun use case for this related to https://docs.rs/iddqd: as part of it I need a sorted set with a custom comparator which must be passed in (data required for comparisons cannot really be stored on the elements themselves). I'm currently using a thread-local for this purpose, but I realized that For the three basic operations, find, insert, and remove:
I've written up some notes at https://github.com/oxidecomputer/iddqd/blob/37da27bc6eb62f23e19f947b0487e01bd17bf209/crates/iddqd/src/support/btree_table.rs#L21-L66, and I have a PoC showing I know this is pushing the limits of what's legal with |
Uh oh!
There was an error while loading. Please reload this page.
Feature gate:
#![feature(btree_set_entry)]
This is a tracking issue for
Entry
and entry-like methods onBTreeSet
.Public API
Steps / History
BTreeSet
entry APIs to matchHashSet
#133548Unresolved Questions
See also #60896 for
HashSet
.Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: