summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorJeff Dickey <216188+jdxcode@users.noreply.github.com>2019-11-01 19:42:33 -0700
committerJeff Dickey <216188+jdxcode@users.noreply.github.com>2019-11-01 20:18:33 -0700
commitd9ec5fa88ca0c082aa2089b372e7981f9d514e82 (patch)
treeea8f6199acc3b92e0b1bf0e7f2f7daf4e28bdcd1 /src/libcore
parent87cbf0a547aaf9e8a7fc708851ecf4bc2adab5fd (diff)
downloadrust-d9ec5fa88ca0c082aa2089b372e7981f9d514e82.tar.gz
rust-d9ec5fa88ca0c082aa2089b372e7981f9d514e82.zip
doc(str): show example of chars().count() under len()
the docs are great at explaining that .len() isn't like in other
languages but stops short of explaining how to get the character length.

r? @steveklabnik
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index f67012d8f2f..1968919f554 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -2085,8 +2085,8 @@ impl str {
     /// let len = "foo".len();
     /// assert_eq!(3, len);
     ///
-    /// let len = "ƒoo".len(); // fancy f!
-    /// assert_eq!(4, len);
+    /// assert_eq!("ƒoo".len(), 4); // fancy f!
+    /// assert_eq!("ƒoo".chars().count(), 3);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]