Skip to content

Commit

Permalink
Add Dictionary::swap_remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Jan 3, 2025
1 parent bd9d921 commit 73feacd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/types/src/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ impl Dictionary {
#[allow(clippy::unnecessary_struct_initialization)]
NonOwning::new(Self(KVec { ..self.0 }))
}

/// Removes a `KeyValuePair` from the `Dictionary` and returns it.
///
/// The removed pair is replaced by the last element of the dictionary.
///
/// # Panics
///
/// Panics if `index` is out of bounds.
#[track_caller]
#[inline]
pub fn swap_remove(&mut self, index: usize) -> KeyValuePair {
self.0.swap_remove(index)
}
}

impl KeyValuePair {
Expand Down

0 comments on commit 73feacd

Please sign in to comment.