From d9ec5fa88ca0c082aa2089b372e7981f9d514e82 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Fri, 1 Nov 2019 19:42:33 -0700 Subject: 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 --- src/libcore/str/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcore') 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] -- cgit 1.4.1-3-g733a5