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 4a95e97 commit d73c23dCopy full SHA for d73c23d
src/libcore/slice/mod.rs
@@ -1263,6 +1263,14 @@ impl<T> [T] {
1263
/// assert!(v.contains(&30));
1264
/// assert!(!v.contains(&50));
1265
/// ```
1266
+ ///
1267
+ /// If you only have a borrowed `T`, use `any`:
1268
1269
+ /// ```
1270
+ /// let v = [String::from("hello"), String::from("world")];
1271
+ /// assert!(v.iter().any(|e| e == "hello"));
1272
+ /// assert!(!v.iter().any(|e| e == "hi"));
1273
1274
#[stable(feature = "rust1", since = "1.0.0")]
1275
pub fn contains(&self, x: &T) -> bool
1276
where T: PartialEq
0 commit comments