Skip to content

Commit ecb85f0

Browse files
into_inner example: prefer "imperative" if let over .map()
Co-authored-by: Daniel Henry-Mantilla <[email protected]>
1 parent cd444ca commit ecb85f0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/alloc/src/sync.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,11 @@ impl<T> Arc<T> {
588588
/// // manual `Drop` implementation that does the destruction in a loop:
589589
/// impl<T> Drop for LinkedList<T> {
590590
/// fn drop(&mut self) {
591-
/// let mut x = self.0.take();
592-
/// while let Some(arc) = x.take() {
593-
/// Arc::into_inner(arc).map(|node| x = node.1);
591+
/// let mut link = self.0.take();
592+
/// while let Some(arc_node) = link.take() {
593+
/// if let Some(Node(_value, next)) = Arc::into_inner(arc_node) {
594+
/// link = next;
595+
/// }
594596
/// }
595597
/// }
596598
/// }

0 commit comments

Comments
 (0)