Skip to content

Commit

Permalink
Rollup merge of rust-lang#84878 - jimblandy:contains-doc-fix, r=josht…
Browse files Browse the repository at this point in the history
…riplett

Clarify documentation for `[T]::contains`. Fixes rust-lang#84877.

Change the documentation to correctly characterize when the suggested alternative to `contains` applies, and correctly explain why it works.
  • Loading branch information
Dylan-DPC committed May 4, 2021
2 parents 2911b93 + d53469c commit 042bec8
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 042bec8

Please sign in to comment.