Skip to content

Remove surplus prepend LinkedList fn #85571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove surplus prepend LinkedList fn
Originally committed to Rust in 2013, it is identical to append
with a reversed order of arguments.
  • Loading branch information
workingjubilee committed May 21, 2021
commit c516e7187423a7db1f61178ff05fb6512f279c8d
21 changes: 0 additions & 21 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,27 +442,6 @@ impl<T> LinkedList<T> {
}
}

/// Moves all elements from `other` to the begin of the list.
#[unstable(feature = "linked_list_prepend", issue = "none")]
pub fn prepend(&mut self, other: &mut Self) {
match self.head {
None => mem::swap(self, other),
Some(mut head) => {
// `as_mut` is okay here because we have exclusive access to the entirety
// of both lists.
if let Some(mut other_tail) = other.tail.take() {
unsafe {
head.as_mut().prev = Some(other_tail);
other_tail.as_mut().next = Some(head);
}

self.head = other.head.take();
self.len += mem::replace(&mut other.len, 0);
}
}
}
}

/// Provides a forward iterator.
///
/// # Examples
Expand Down