We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d73c23d commit 3f77f2cCopy full SHA for 3f77f2c
src/libcore/slice/mod.rs
@@ -1264,11 +1264,12 @@ impl<T> [T] {
1264
/// assert!(!v.contains(&50));
1265
/// ```
1266
///
1267
- /// 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>`
1268
+ /// (e.g. `String: Borrow<str>`), you can use `iter().any`:
1269
1270
- /// let v = [String::from("hello"), String::from("world")];
1271
- /// assert!(v.iter().any(|e| e == "hello"));
+ /// let v = [String::from("hello"), String::from("world")]; // slice of `String`
1272
+ /// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
1273
/// assert!(!v.iter().any(|e| e == "hi"));
1274
1275
#[stable(feature = "rust1", since = "1.0.0")]
0 commit comments