File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1264,11 +1264,12 @@ impl<T> [T] {
12641264 /// assert!(!v.contains(&50));
12651265 /// ```
12661266 ///
1267- /// If you only have a borrowed `T`, use `any`:
1267+ /// If you do not have an `&T`, but just an `&U` such that `T: Borrow<U>`
1268+ /// (e.g. `String: Borrow<str>`), you can use `iter().any`:
12681269 ///
12691270 /// ```
1270- /// let v = [String::from("hello"), String::from("world")];
1271- /// assert!(v.iter().any(|e| e == "hello"));
1271+ /// let v = [String::from("hello"), String::from("world")]; // slice of `String`
1272+ /// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
12721273 /// assert!(!v.iter().any(|e| e == "hi"));
12731274 /// ```
12741275 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments