Clarify documentation for [T]::contains. Fixes #84877.

This commit is contained in:
Jim Blandy 2021-05-03 12:01:16 -07:00
parent 716394d658
commit d53469c1d3

View File

@ -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`