Skip to content

Commit 042bec8

Browse files
authored
Rollup merge of rust-lang#84878 - jimblandy:contains-doc-fix, r=joshtriplett
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.
2 parents 2911b93 + d53469c commit 042bec8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/core/src/slice/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1948,8 +1948,9 @@ impl<T> [T] {
19481948
/// assert!(!v.contains(&50));
19491949
/// ```
19501950
///
1951-
/// If you do not have an `&T`, but just an `&U` such that `T: Borrow<U>`
1952-
/// (e.g. `String: Borrow<str>`), you can use `iter().any`:
1951+
/// If you do not have a `&T`, but some other value that you can compare
1952+
/// with one (for example, `String` implements `PartialEq<str>`), you can
1953+
/// use `iter().any`:
19531954
///
19541955
/// ```
19551956
/// let v = [String::from("hello"), String::from("world")]; // slice of `String`

0 commit comments

Comments
 (0)