]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #84878 - jimblandy:contains-doc-fix, r=joshtriplett
authorRalf Jung <post@ralfj.de>
Wed, 5 May 2021 15:52:26 +0000 (17:52 +0200)
committerGitHub <noreply@github.com>
Wed, 5 May 2021 15:52:26 +0000 (17:52 +0200)
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

library/core/src/slice/mod.rs

index ec28cdd1ba0d9cf166ccf869ce70d77b94c6a1c0..0923175414edd1786bac00de3575119ee25a0f7d 100644 (file)
@@ -1948,8 +1948,9 @@ pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<'_, T, F>
     /// 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`