diff --git a/src/doc/implementing_self_referential_data_structures.rs b/src/doc/implementing_self_referential_data_structures.rs index f7b5746da..b22ed996c 100644 --- a/src/doc/implementing_self_referential_data_structures.rs +++ b/src/doc/implementing_self_referential_data_structures.rs @@ -31,7 +31,7 @@ //! Rc::unadopt(&head, tail); //! Rc::unadopt(tail, &head); //! -//! tail.borrow_mut().next = next.as_ref().map(Rc::clone); +//! tail.borrow_mut().next = next.clone(); //! if let Some(ref next) = next { //! unsafe { //! Rc::adopt_unchecked(tail, next); @@ -42,7 +42,7 @@ //! Rc::unadopt(&head, next); //! Rc::unadopt(next, &head); //! -//! next.borrow_mut().prev = tail.as_ref().map(Rc::clone); +//! next.borrow_mut().prev = tail.clone(); //! if let Some(ref tail) = tail { //! unsafe { //! Rc::adopt_unchecked(next, tail); diff --git a/tests/leak_doubly_linked_list.rs b/tests/leak_doubly_linked_list.rs index 07c64f347..0db0d51c5 100644 --- a/tests/leak_doubly_linked_list.rs +++ b/tests/leak_doubly_linked_list.rs @@ -25,7 +25,7 @@ impl List { Rc::unadopt(&head, tail); Rc::unadopt(tail, &head); - tail.borrow_mut().next = next.as_ref().map(Rc::clone); + tail.borrow_mut().next = next.clone(); if let Some(ref next) = next { unsafe { Rc::adopt_unchecked(tail, next); @@ -36,7 +36,7 @@ impl List { Rc::unadopt(&head, next); Rc::unadopt(next, &head); - next.borrow_mut().prev = tail.as_ref().map(Rc::clone); + next.borrow_mut().prev = tail.clone(); if let Some(ref tail) = tail { unsafe { Rc::adopt_unchecked(next, tail);