Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbba2200

Browse files
committed
LinkedList's Cursor: method to get a ref to the cursor's list
1 parenta6b22e9 commitbba2200

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎alloc/src/collections/linked_list.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,14 @@ impl<'a, T, A: Allocator> Cursor<'a, T, A> {
14951495
pubfnback(&self) ->Option<&'aT>{
14961496
self.list.back()
14971497
}
1498+
1499+
/// Provides a reference to the cursor's parent list.
1500+
#[must_use]
1501+
#[inline(always)]
1502+
#[unstable(feature ="linked_list_cursors", issue ="58533")]
1503+
pubfnas_list(&self) ->&'aLinkedList<T,A>{
1504+
self.list
1505+
}
14981506
}
14991507

15001508
impl<'a,T,A:Allocator>CursorMut<'a,T,A>{
@@ -1605,6 +1613,18 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> {
16051613
pubfnas_cursor(&self) ->Cursor<'_,T,A>{
16061614
Cursor{list:self.list,current:self.current,index:self.index}
16071615
}
1616+
1617+
/// Provides a read-only reference to the cursor's parent list.
1618+
///
1619+
/// The lifetime of the returned reference is bound to that of the
1620+
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
1621+
/// `CursorMut` is frozen for the lifetime of the reference.
1622+
#[must_use]
1623+
#[inline(always)]
1624+
#[unstable(feature ="linked_list_cursors", issue ="58533")]
1625+
pubfnas_list(&self) ->&LinkedList<T,A>{
1626+
self.list
1627+
}
16081628
}
16091629

16101630
// Now the list editing operations

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp