diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-09-15 22:09:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-15 22:09:49 +0200 |
| commit | 98ab2b0e80c158466e6e5237f4da9245c0543046 (patch) | |
| tree | dcd9a96ce9beb08e91888b763aa869f05a3d20b9 | |
| parent | 1f363a1921c1b067af4cb31613a00d69ef6cacd1 (diff) | |
| parent | ce859d7713dbca1b2a3dff17ccc4d4a0598bffbf (diff) | |
| download | rust-98ab2b0e80c158466e6e5237f4da9245c0543046.tar.gz rust-98ab2b0e80c158466e6e5237f4da9245c0543046.zip | |
Rollup merge of #146546 - cammeresi:pop, r=Mark-Simulacrum
Switch `std::vec::PeekMut::pop` from self to this parameter. Since PeekMut implements Deref, it shouldn't have any methods of its own. See also: `std::collections::binary_heap::PeekMut::pop` Pointed out: https://github.com/rust-lang/rust/issues/122742#issuecomment-3064050551 Related: rust-lang/rust#122742
| -rw-r--r-- | .mailmap | 1 | ||||
| -rw-r--r-- | library/alloc/src/vec/peek_mut.rs | 4 | ||||
| -rw-r--r-- | library/alloctests/tests/vec.rs | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/.mailmap b/.mailmap index 6e3eed1226e..0f7bc5e38bd 100644 --- a/.mailmap +++ b/.mailmap @@ -609,6 +609,7 @@ Shohei Wada <pc@wada314.jp> Shotaro Yamada <sinkuu@sinkuu.xyz> Shotaro Yamada <sinkuu@sinkuu.xyz> <sinkuu@users.noreply.github.com> Shyam Sundar B <shyambaskaran@outlook.com> +Sidney Cammeresi <sac@cheesecake.org> <sac@readyset.io> Simon Barber-Dueck <sbarberdueck@gmail.com> Simon BD <simon@server> Simon Sapin <simon@exyr.org> <simon.sapin@exyr.org> Simonas Kazlauskas <git@kazlauskas.me> Simonas Kazlauskas <github@kazlauskas.me> diff --git a/library/alloc/src/vec/peek_mut.rs b/library/alloc/src/vec/peek_mut.rs index c0dd941ed39..caeaf2799d7 100644 --- a/library/alloc/src/vec/peek_mut.rs +++ b/library/alloc/src/vec/peek_mut.rs @@ -29,9 +29,9 @@ impl<'a, T> PeekMut<'a, T> { /// Removes the peeked value from the vector and returns it. #[unstable(feature = "vec_peek_mut", issue = "122742")] - pub fn pop(self) -> T { + pub fn pop(this: Self) -> T { // SAFETY: PeekMut is only constructed if the vec is non-empty - unsafe { self.vec.pop().unwrap_unchecked() } + unsafe { this.vec.pop().unwrap_unchecked() } } } diff --git a/library/alloctests/tests/vec.rs b/library/alloctests/tests/vec.rs index 00f640cd17e..404eb49e1ea 100644 --- a/library/alloctests/tests/vec.rs +++ b/library/alloctests/tests/vec.rs @@ -15,7 +15,7 @@ use std::ops::Bound::*; use std::panic::{AssertUnwindSafe, catch_unwind}; use std::rc::Rc; use std::sync::atomic::{AtomicU32, Ordering}; -use std::vec::{Drain, IntoIter}; +use std::vec::{Drain, IntoIter, PeekMut}; use crate::testing::macros::struct_with_counted_drop; @@ -2647,7 +2647,7 @@ fn test_peek_mut() { assert_eq!(*p, 2); *p = 0; assert_eq!(*p, 0); - p.pop(); + PeekMut::pop(p); assert_eq!(vec.len(), 1); } else { unreachable!() |
