mirror of
https://github.com/Noratrieb/datastructures.git
synced 2026-01-15 18:05:02 +01:00
miri did not like Node::remove. miri was right.
This commit is contained in:
parent
38b85968cf
commit
ffde519487
2 changed files with 3 additions and 27 deletions
|
|
@ -394,19 +394,6 @@ impl<T> Node<T> {
|
|||
pub fn replace_value(&mut self, value: T) -> T {
|
||||
std::mem::replace(&mut self.value, value)
|
||||
}
|
||||
|
||||
/// Removes a value from the List and returns it
|
||||
pub fn remove(&mut self) -> T {
|
||||
// SAFETY: All pointers should always be valid
|
||||
unsafe {
|
||||
self.next.map(|mut next| next.as_mut().prev = self.prev);
|
||||
self.prev.map(|mut prev| prev.as_mut().next = self.next);
|
||||
}
|
||||
|
||||
// SAFETY: A reference is always valid and we have the only one now
|
||||
let node = unsafe { Box::from_raw(self) };
|
||||
node.value
|
||||
}
|
||||
}
|
||||
|
||||
fn allocate_nonnull<T>(element: T) -> NonNull<T> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue