about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-07-28 22:09:31 -0400
committerCorey Farwell <coreyf@rwell.org>2016-07-28 22:09:31 -0400
commitf459e801fd6cfad61e81ed12e6c364f0776d6ed4 (patch)
treeb857d851f90f428885d8d49714ad4b9ee3491529
parentd1df3fecdf8dc959fbd8901603a16e5bc0bfa21d (diff)
downloadrust-f459e801fd6cfad61e81ed12e6c364f0776d6ed4.tar.gz
rust-f459e801fd6cfad61e81ed12e6c364f0776d6ed4.zip
Rewrite `collections::LinkedList::append` doc example.
-rw-r--r--src/libcollections/linked_list.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs
index 3d5c3125fae..6842f02e0e1 100644
--- a/src/libcollections/linked_list.rs
+++ b/src/libcollections/linked_list.rs
@@ -203,19 +203,22 @@ impl<T> LinkedList<T> {
     /// ```
     /// use std::collections::LinkedList;
     ///
-    /// let mut a = LinkedList::new();
-    /// let mut b = LinkedList::new();
-    /// a.push_back(1);
-    /// a.push_back(2);
-    /// b.push_back(3);
-    /// b.push_back(4);
+    /// let mut list1 = LinkedList::new();
+    /// list1.push_back('a');
     ///
-    /// a.append(&mut b);
+    /// let mut list2 = LinkedList::new();
+    /// list2.push_back('b');
+    /// list2.push_back('c');
     ///
-    /// for e in &a {
-    ///     println!("{}", e); // prints 1, then 2, then 3, then 4
-    /// }
-    /// println!("{}", b.len()); // prints 0
+    /// list1.append(&mut list2);
+    ///
+    /// let mut iter = list1.iter();
+    /// assert_eq!(iter.next(), Some(&'a'));
+    /// assert_eq!(iter.next(), Some(&'b'));
+    /// assert_eq!(iter.next(), Some(&'c'));
+    /// assert!(iter.next().is_none());
+    ///
+    /// assert!(list2.is_empty());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn append(&mut self, other: &mut Self) {