diff options
| author | bors <bors@rust-lang.org> | 2024-07-07 16:29:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-07 16:29:52 +0000 |
| commit | 0ca92de4733bf31262200c6d37e722f534cef4bc (patch) | |
| tree | 5e0a88d47317a3b3ab7da850dac8c723a8a9407b /library/alloc/src | |
| parent | 959a2eb275c732ccc9153f0503dd64896533e997 (diff) | |
| parent | b564c510c1b794cfb2e59ef64d14ffcdc22db6f5 (diff) | |
| download | rust-0ca92de4733bf31262200c6d37e722f534cef4bc.tar.gz rust-0ca92de4733bf31262200c6d37e722f534cef4bc.zip | |
Auto merge of #127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #127179 (Print `TypeId` as hex for debugging) - #127189 (LinkedList's Cursor: method to get a ref to the cursor's list) - #127236 (doc: update config file path in platform-support/wasm32-wasip1-threads.md) - #127297 (Improve std::Path's Hash quality by avoiding prefix collisions) - #127308 (Attribute cleanups) - #127354 (Describe Sized requirements for mem::offset_of) - #127409 (Emit a wrap expr span_bug only if context is not tainted) - #127447 (once_lock: make test not take as long in Miri) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/linked_list.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 01510a61405..077483a174b 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1495,6 +1495,14 @@ impl<'a, T, A: Allocator> Cursor<'a, T, A> { pub fn back(&self) -> Option<&'a T> { self.list.back() } + + /// Provides a reference to the cursor's parent list. + #[must_use] + #[inline(always)] + #[unstable(feature = "linked_list_cursors", issue = "58533")] + pub fn as_list(&self) -> &'a LinkedList<T, A> { + self.list + } } impl<'a, T, A: Allocator> CursorMut<'a, T, A> { @@ -1605,6 +1613,18 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> { pub fn as_cursor(&self) -> Cursor<'_, T, A> { Cursor { list: self.list, current: self.current, index: self.index } } + + /// Provides a read-only reference to the cursor's parent list. + /// + /// The lifetime of the returned reference is bound to that of the + /// `CursorMut`, which means it cannot outlive the `CursorMut` and that the + /// `CursorMut` is frozen for the lifetime of the reference. + #[must_use] + #[inline(always)] + #[unstable(feature = "linked_list_cursors", issue = "58533")] + pub fn as_list(&self) -> &LinkedList<T, A> { + self.list + } } // Now the list editing operations |
