Skip to content

Commit

Permalink
Add doc aliases like BTreeMap/BTreeSet
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Aug 28, 2024
1 parent e1f5f26 commit 264e5b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ impl<K, V, S> IndexMap<K, V, S> {
/// This preserves the order of the remaining elements.
///
/// Computes in **O(1)** time (average).
#[doc(alias = "pop_last")] // like `BTreeMap`
pub fn pop(&mut self) -> Option<(K, V)> {
self.core.pop()
}
Expand Down Expand Up @@ -1087,6 +1088,7 @@ impl<K, V, S> IndexMap<K, V, S> {
/// Get the first key-value pair
///
/// Computes in **O(1)** time.
#[doc(alias = "first_key_value")] // like `BTreeMap`
pub fn first(&self) -> Option<(&K, &V)> {
self.as_entries().first().map(Bucket::refs)
}
Expand All @@ -1108,6 +1110,7 @@ impl<K, V, S> IndexMap<K, V, S> {
/// Get the last key-value pair
///
/// Computes in **O(1)** time.
#[doc(alias = "last_key_value")] // like `BTreeMap`
pub fn last(&self) -> Option<(&K, &V)> {
self.as_entries().last().map(Bucket::refs)
}
Expand Down
1 change: 1 addition & 0 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ impl<T, S> IndexSet<T, S> {
/// This preserves the order of the remaining elements.
///
/// Computes in **O(1)** time (average).
#[doc(alias = "pop_last")] // like `BTreeSet`
pub fn pop(&mut self) -> Option<T> {
self.map.pop().map(|(x, ())| x)
}
Expand Down

0 comments on commit 264e5b7

Please sign in to comment.