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] {
1264
1264
/// assert!(!v.contains(&50));
1265
1265
/// ```
1266
1266
///
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`:
1268
1269
///
1269
1270
/// ```
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`
1272
1273
/// assert!(!v.iter().any(|e| e == "hi"));
1273
1274
/// ```
1274
1275
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments