From 3f77f2cd5bedf364d4226df139e7369761bd41a2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 14 Jul 2019 10:03:04 +0200 Subject: better comments --- src/libcore/slice/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/libcore') 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] { /// 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` + /// (e.g. `String: Borrow`), 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")] -- cgit 1.4.1-3-g733a5