Skip to content

Commit

Permalink
Rollup merge of #84878 - jimblandy:contains-doc-fix, r=joshtriplett
Browse files Browse the repository at this point in the history
Clarify documentation for `[T]::contains`

Change the documentation to correctly characterize when the suggested alternative to `contains` applies, and correctly explain why it works.

Fixes #84877
  • Loading branch information
RalfJung authored May 5, 2021
2 parents b2bb687 + d53469c commit 92f3f08
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 92f3f08

Please sign in to comment.