Clarify documentation for [T]::contains
. Fixes #84877.
This commit is contained in:
parent
716394d658
commit
d53469c1d3
@ -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`
|
||||
|
Loading…
x
Reference in New Issue
Block a user