Skip to content

Commit

Permalink
better comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 14, 2019
1 parent d73c23d commit 3f77f2c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,11 +1264,12 @@ impl<T> [T] {
/// assert!(!v.contains(&50));
/// ```
///
/// 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>`
/// (e.g. `String: Borrow<str>`), you can use `iter().any`:
///
/// ```
/// let v = [String::from("hello"), String::from("world")];
/// assert!(v.iter().any(|e| e == "hello"));
/// let v = [String::from("hello"), String::from("world")]; // slice of `String`
/// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
/// assert!(!v.iter().any(|e| e == "hi"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 3f77f2c

Please sign in to comment.