about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libcore/slice/mod.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index c3eb2ec9dc2..edd00a9fa85 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -1264,11 +1264,12 @@ impl<T> [T] {
     /// assert!(!v.contains(&50));
     /// ```
     ///
-    /// If you only have a borrowed `T`, use `any`:
+    /// If you do not have an `&T`, but just an `&U` such that `T: Borrow<U>`
+    /// (e.g. `String: Borrow<str>`), you can use `iter().any`:
     ///
     /// ```
-    /// let v = [String::from("hello"), String::from("world")];
-    /// assert!(v.iter().any(|e| e == "hello"));
+    /// let v = [String::from("hello"), String::from("world")]; // slice of `String`
+    /// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
     /// assert!(!v.iter().any(|e| e == "hi"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]