diff options
| author | Ralf Jung <post@ralfj.de> | 2019-07-14 10:03:04 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2019-07-14 10:03:04 +0200 |
| commit | 3f77f2cd5bedf364d4226df139e7369761bd41a2 (patch) | |
| tree | 9a9f266b854cb3a5929d1c7faa0e865a513f808b | |
| parent | d73c23d114d109d7c48c9447f53bcba533effa16 (diff) | |
| download | rust-3f77f2cd5bedf364d4226df139e7369761bd41a2.tar.gz rust-3f77f2cd5bedf364d4226df139e7369761bd41a2.zip | |
better comments
| -rw-r--r-- | src/libcore/slice/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index c3eb2ec9dc2..edd00a9fa85 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1264,11 +1264,12 @@ impl<T> [T] { /// assert!(!v.contains(&50)); /// ``` /// - /// If you only have a borrowed `T`, use `any`: + /// 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`: /// /// ``` - /// let v = [String::from("hello"), String::from("world")]; - /// assert!(v.iter().any(|e| e == "hello")); + /// let v = [String::from("hello"), String::from("world")]; // slice of `String` + /// assert!(v.iter().any(|e| e == "hello")); // search with `&str` /// assert!(!v.iter().any(|e| e == "hi")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] |
