Skip to content

Commit

Permalink
Clarify documentation for [T]::contains. Fixes #84877.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed May 3, 2021
1 parent 716394d commit d53469c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,9 @@ impl<T> [T] {
/// assert!(!v.contains(&50));
/// ```
///
/// 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`:
/// If you do not have a `&T`, but some other value that you can compare
/// with one (for example, `String` implements `PartialEq<str>`), you can
/// use `iter().any`:
///
/// ```
/// let v = [String::from("hello"), String::from("world")]; // slice of `String`
Expand Down

0 comments on commit d53469c

Please sign in to comment.