Rollup merge of #74644 - crlf0710:drop_old_stuff, r=Amanieu

Remove `linked_list_extras` methods.

Removing these in favor of the `Cursor` API in https://github.com/rust-lang/rust/issues/58533 .
Closes #27794.

r? @Amanieu
This commit is contained in:
Yuki Okushi 2020-08-01 08:02:04 +09:00 committed by GitHub
commit ab4570eaf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 62 deletions

View file

@ -1110,32 +1110,17 @@ impl<T> IterMut<'_, T> {
/// Inserts the given element just after the element most recently returned by `.next()`.
/// The inserted element does not appear in the iteration.
///
/// # Examples
///
/// ```
/// #![feature(linked_list_extras)]
///
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();
///
/// {
/// let mut it = list.iter_mut();
/// assert_eq!(it.next().unwrap(), &1);
/// // insert `2` after `1`
/// it.insert_next(2);
/// }
/// {
/// let vec: Vec<_> = list.into_iter().collect();
/// assert_eq!(vec, [1, 2, 3, 4]);
/// }
/// ```
/// This method will be removed soon.
#[inline]
#[unstable(
feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see",
issue = "27794"
)]
#[rustc_deprecated(
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
since = "1.47.0"
)]
pub fn insert_next(&mut self, element: T) {
match self.head {
// `push_back` is okay with aliasing `element` references
@ -1163,27 +1148,17 @@ impl<T> IterMut<'_, T> {
/// Provides a reference to the next element, without changing the iterator.
///
/// # Examples
///
/// ```
/// #![feature(linked_list_extras)]
///
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect();
///
/// let mut it = list.iter_mut();
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.peek_next().unwrap(), &2);
/// // We just peeked at 2, so it was not consumed from the iterator.
/// assert_eq!(it.next().unwrap(), &2);
/// ```
/// This method will be removed soon.
#[inline]
#[unstable(
feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see",
issue = "27794"
)]
#[rustc_deprecated(
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
since = "1.47.0"
)]
pub fn peek_next(&mut self) -> Option<&mut T> {
if self.len == 0 {
None

View file

@ -153,33 +153,6 @@ fn test_clone_from() {
}
}
#[test]
fn test_insert_prev() {
let mut m = list_from(&[0, 2, 4, 6, 8]);
let len = m.len();
{
let mut it = m.iter_mut();
it.insert_next(-2);
loop {
match it.next() {
None => break,
Some(elt) => {
it.insert_next(*elt + 1);
match it.peek_next() {
Some(x) => assert_eq!(*x, *elt + 2),
None => assert_eq!(8, *elt),
}
}
}
}
it.insert_next(0);
it.insert_next(1);
}
check_links(&m);
assert_eq!(m.len(), 3 + len * 2);
assert_eq!(m.into_iter().collect::<Vec<_>>(), [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]);
}
#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
fn test_send() {