Skip to content

Commit ab4570e

Browse files
authored
Rollup merge of #74644 - crlf0710:drop_old_stuff, r=Amanieu
Remove `linked_list_extras` methods. Removing these in favor of the `Cursor` API in #58533 . Closes #27794. r? @Amanieu
2 parents 6e87bac + dc21178 commit ab4570e

File tree

2 files changed

+10
-62
lines changed

2 files changed

+10
-62
lines changed

library/alloc/src/collections/linked_list.rs

+10-35
Original file line numberDiff line numberDiff line change
@@ -1110,32 +1110,17 @@ impl<T> IterMut<'_, T> {
11101110
/// Inserts the given element just after the element most recently returned by `.next()`.
11111111
/// The inserted element does not appear in the iteration.
11121112
///
1113-
/// # Examples
1114-
///
1115-
/// ```
1116-
/// #![feature(linked_list_extras)]
1117-
///
1118-
/// use std::collections::LinkedList;
1119-
///
1120-
/// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();
1121-
///
1122-
/// {
1123-
/// let mut it = list.iter_mut();
1124-
/// assert_eq!(it.next().unwrap(), &1);
1125-
/// // insert `2` after `1`
1126-
/// it.insert_next(2);
1127-
/// }
1128-
/// {
1129-
/// let vec: Vec<_> = list.into_iter().collect();
1130-
/// assert_eq!(vec, [1, 2, 3, 4]);
1131-
/// }
1132-
/// ```
1113+
/// This method will be removed soon.
11331114
#[inline]
11341115
#[unstable(
11351116
feature = "linked_list_extras",
11361117
reason = "this is probably better handled by a cursor type -- we'll see",
11371118
issue = "27794"
11381119
)]
1120+
#[rustc_deprecated(
1121+
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
1122+
since = "1.47.0"
1123+
)]
11391124
pub fn insert_next(&mut self, element: T) {
11401125
match self.head {
11411126
// `push_back` is okay with aliasing `element` references
@@ -1163,27 +1148,17 @@ impl<T> IterMut<'_, T> {
11631148

11641149
/// Provides a reference to the next element, without changing the iterator.
11651150
///
1166-
/// # Examples
1167-
///
1168-
/// ```
1169-
/// #![feature(linked_list_extras)]
1170-
///
1171-
/// use std::collections::LinkedList;
1172-
///
1173-
/// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect();
1174-
///
1175-
/// let mut it = list.iter_mut();
1176-
/// assert_eq!(it.next().unwrap(), &1);
1177-
/// assert_eq!(it.peek_next().unwrap(), &2);
1178-
/// // We just peeked at 2, so it was not consumed from the iterator.
1179-
/// assert_eq!(it.next().unwrap(), &2);
1180-
/// ```
1151+
/// This method will be removed soon.
11811152
#[inline]
11821153
#[unstable(
11831154
feature = "linked_list_extras",
11841155
reason = "this is probably better handled by a cursor type -- we'll see",
11851156
issue = "27794"
11861157
)]
1158+
#[rustc_deprecated(
1159+
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
1160+
since = "1.47.0"
1161+
)]
11871162
pub fn peek_next(&mut self) -> Option<&mut T> {
11881163
if self.len == 0 {
11891164
None

library/alloc/src/collections/linked_list/tests.rs

-27
Original file line numberDiff line numberDiff line change
@@ -153,33 +153,6 @@ fn test_clone_from() {
153153
}
154154
}
155155

156-
#[test]
157-
fn test_insert_prev() {
158-
let mut m = list_from(&[0, 2, 4, 6, 8]);
159-
let len = m.len();
160-
{
161-
let mut it = m.iter_mut();
162-
it.insert_next(-2);
163-
loop {
164-
match it.next() {
165-
None => break,
166-
Some(elt) => {
167-
it.insert_next(*elt + 1);
168-
match it.peek_next() {
169-
Some(x) => assert_eq!(*x, *elt + 2),
170-
None => assert_eq!(8, *elt),
171-
}
172-
}
173-
}
174-
}
175-
it.insert_next(0);
176-
it.insert_next(1);
177-
}
178-
check_links(&m);
179-
assert_eq!(m.len(), 3 + len * 2);
180-
assert_eq!(m.into_iter().collect::<Vec<_>>(), [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]);
181-
}
182-
183156
#[test]
184157
#[cfg_attr(target_os = "emscripten", ignore)]
185158
fn test_send() {

0 commit comments

Comments
 (0)