Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for BTreeSet entry APIs #133549

Open
3 tasks
cuviper opened this issue Nov 27, 2024 · 0 comments
Open
3 tasks

Tracking Issue for BTreeSet entry APIs #133549

cuviper opened this issue Nov 27, 2024 · 0 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@cuviper
Copy link
Member

cuviper commented Nov 27, 2024

Feature gate: #![feature(btree_set_entry)]

This is a tracking issue for Entry and entry-like methods on BTreeSet.

Public API

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,
    {...}
}

pub enum Entry<'a, T, A: Allocator + Clone = Global> {
    Occupied(OccupiedEntry<'a, T, A>),
    Vacant(VacantEntry<'a, T, A>),
}
pub struct OccupiedEntry<'a, T, A: Allocator + Clone = Global> {...}
pub struct VacantEntry<'a, T, A: Allocator + Clone = Global> {...}

impl<T: Debug + Ord, A: Allocator + Clone> Debug for Entry<'_, T, A> {...}
impl<T: Debug + Ord, A: Allocator + Clone> Debug for OccupiedEntry<'_, T, A> {...}
impl<T: Debug + Ord, A: Allocator + Clone> Debug for VacantEntry<'_, T, A> {...}

impl<'a, T: Ord, A: Allocator + Clone> Entry<'a, T, A> {
    pub fn insert(self) -> OccupiedEntry<'a, T, A> {...}
    pub fn or_insert(self) {...}
    pub fn get(&self) -> &T {...}
}

impl<'a, T: Ord, A: Allocator + Clone> OccupiedEntry<'a, T, A> {
    pub fn get(&self) -> &T {...}
    pub fn remove(self) -> T {...}
}

impl<'a, T: Ord, A: Allocator + Clone> VacantEntry<'a, T, A> {
    pub fn get(&self) -> &T {...}
    pub fn into_value(self) -> T {...}
    pub fn insert(self) {...}
}

Steps / History

Unresolved Questions

  • None yet.

See also #60896 for HashSet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@cuviper cuviper added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant