Skip to content

Commit

Permalink
Add proper lifetime to RawOccupiedEntryMut
Browse files Browse the repository at this point in the history
  • Loading branch information
ChosenName committed Nov 29, 2024
1 parent 2082249 commit 9a85fbb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/raw_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// }
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn key(&self) -> &K {
pub fn key(&self) -> &'a K {
unsafe { &self.elem.as_ref().0 }
}

Expand Down Expand Up @@ -948,7 +948,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2);
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn key_mut(&mut self) -> &mut K {
pub fn key_mut(&mut self) -> &'a mut K {
unsafe { &mut self.elem.as_mut().0 }
}

Expand Down Expand Up @@ -1001,7 +1001,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// }
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn get(&self) -> &V {
pub fn get(&self) -> &'a V {
unsafe { &self.elem.as_ref().1 }
}

Expand Down Expand Up @@ -1047,7 +1047,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// assert_eq!(map[&"a"], 1000);
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn get_mut(&mut self) -> &mut V {
pub fn get_mut(&mut self) -> &'a mut V {
unsafe { &mut self.elem.as_mut().1 }
}

Expand All @@ -1066,7 +1066,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// }
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn get_key_value(&self) -> (&K, &V) {
pub fn get_key_value(&self) -> (&'a K, &'a V) {
unsafe {
let (key, value) = self.elem.as_ref();
(key, value)
Expand Down Expand Up @@ -1102,7 +1102,7 @@ impl<'a, K, V, S, A: Allocator> RawOccupiedEntryMut<'a, K, V, S, A> {
/// assert!(Rc::strong_count(&key_one) == 1 && Rc::strong_count(&key_two) == 2);
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn get_key_value_mut(&mut self) -> (&mut K, &mut V) {
pub fn get_key_value_mut(&mut self) -> (&'a mut K, &'a mut V) {
unsafe {
let &mut (ref mut key, ref mut value) = self.elem.as_mut();
(key, value)
Expand Down

0 comments on commit 9a85fbb

Please sign in to comment.