Skip to content

Commit 10f0296

Browse files
thynsonLAN Xingcan
andauthored
Explicitly annotate lifetime of entry methods (#1141)
The `.key()` and `.value()` should return a borrow whose lifetime aligns with the container, instead of the entry itself. Co-authored-by: LAN Xingcan <lanxingcan@lixiang.com>
1 parent abf24e1 commit 10f0296

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

crossbeam-skiplist/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,12 +1456,12 @@ impl<'a, K: 'a, V: 'a> RefEntry<'a, K, V> {
14561456
}
14571457

14581458
/// Returns a reference to the key.
1459-
pub fn key(&self) -> &K {
1459+
pub fn key(&self) -> &'a K {
14601460
&self.node.key
14611461
}
14621462

14631463
/// Returns a reference to the value.
1464-
pub fn value(&self) -> &V {
1464+
pub fn value(&self) -> &'a V {
14651465
&self.node.value
14661466
}
14671467

crossbeam-skiplist/src/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,12 @@ impl<'a, K, V> Entry<'a, K, V> {
572572
}
573573

574574
/// Returns a reference to the key.
575-
pub fn key(&self) -> &K {
575+
pub fn key(&self) -> &'a K {
576576
self.inner.key()
577577
}
578578

579579
/// Returns a reference to the value.
580-
pub fn value(&self) -> &V {
580+
pub fn value(&self) -> &'a V {
581581
self.inner.value()
582582
}
583583

crossbeam-skiplist/src/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<'a, T> Entry<'a, T> {
455455
}
456456

457457
/// Returns a reference to the value.
458-
pub fn value(&self) -> &T {
458+
pub fn value(&self) -> &'a T {
459459
self.inner.key()
460460
}
461461

0 commit comments

Comments
 (0)