Skip to content

Commit 3f77f2c

Browse files
committed
better comments
1 parent d73c23d commit 3f77f2c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libcore/slice/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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")]

0 commit comments

Comments
 (0)