diff options
| author | Ralf Jung <post@ralfj.de> | 2021-05-05 17:52:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-05 17:52:26 +0200 |
| commit | 92f3f0830f7f4627af1adb7d828527f2aae88017 (patch) | |
| tree | 4db6b0de5c601304b65aac57ce5a6a77f761306b | |
| parent | b2bb6876e0053afcfac2e1d179897191559675de (diff) | |
| parent | d53469c1d350fd47edc08c0419f5a4e58453d110 (diff) | |
| download | rust-92f3f0830f7f4627af1adb7d828527f2aae88017.tar.gz rust-92f3f0830f7f4627af1adb7d828527f2aae88017.zip | |
Rollup merge of #84878 - jimblandy:contains-doc-fix, r=joshtriplett
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
| -rw-r--r-- | library/core/src/slice/mod.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index ec28cdd1ba0..0923175414e 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -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` |
