about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlexis Bourget <alexis.bourget@gmail.com>2020-07-23 23:19:26 +0200
committerAlexis Bourget <alexis.bourget@gmail.com>2020-07-23 23:19:26 +0200
commitf8335fb1e4e17ae035c4553fbf15fec74d92aeb3 (patch)
treef71da446108d406cf17e2fd09fb92c572aaad81e /src/libstd
parent837a761b398a6ff6a97f7f61e390dae9efbeab79 (diff)
downloadrust-f8335fb1e4e17ae035c4553fbf15fec74d92aeb3.tar.gz
rust-f8335fb1e4e17ae035c4553fbf15fec74d92aeb3.zip
Fix nit and add link for Cow
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/keyword_docs.rs40
1 files changed, 8 insertions, 32 deletions
diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs
index 058a89772d4..55a5a290a74 100644
--- a/src/libstd/keyword_docs.rs
+++ b/src/libstd/keyword_docs.rs
@@ -1684,14 +1684,6 @@ mod use_keyword {}
 /// of `shorter`, thus the constraint is respected:
 ///
 /// ```rust
-/// fn select<'a, 'b: 'a>(s1: &'a str, s2: &'b str, second: bool) -> &'a str {
-///     if second {
-///         s2
-///     } else {
-///         s1
-///     }
-/// }
-///
 /// fn select_where<'a, 'b>(s1: &'a str, s2: &'b str, second: bool) -> &'a str
 /// where
 ///     'b: 'a,
@@ -1706,30 +1698,18 @@ mod use_keyword {}
 /// let outer = String::from("Long living ref");
 /// let longer = &outer;
 /// {
-///     let inner = String::from("Long living ref");
+///     let inner = String::from("Short living ref");
 ///     let shorter = &inner;
 ///
-///     assert_eq!(select(shorter, longer, false), shorter);
-///     assert_eq!(select(shorter, longer, true), longer);
-///
 ///     assert_eq!(select_where(shorter, longer, false), shorter);
 ///     assert_eq!(select_where(shorter, longer, true), longer);
 /// }
 /// ```
 ///
 /// On the other hand, this will not compile: `shorter` does not have a lifetime
-/// that respects the constraint imposed by the `select` and `select_where`
-/// functions.
+/// that respects the constraint imposed by the `select_where` functions.
 ///
 /// ```rust,compile_fail,E0597
-/// # fn select<'a, 'b: 'a>(s1: &'a str, s2: &'b str, second: bool) -> &'a str {
-/// #     if second {
-/// #         s2
-/// #     } else {
-/// #         s1
-/// #     }
-/// # }
-/// #
 /// # fn select_where<'a, 'b>(s1: &'a str, s2: &'b str, second: bool) -> &'a str
 /// # where
 /// #     'b: 'a,
@@ -1742,17 +1722,14 @@ mod use_keyword {}
 /// # }
 /// let outer = String::from("Long living ref");
 /// let longer = &outer;
-/// let res1;
-/// let res2;
+/// let res;
 /// {
-///     let inner = String::from("Long living ref");
+///     let inner = String::from("Short living ref");
 ///     let shorter = &inner;
 ///
-///     res1 = select(longer, shorter, false);
-///     res2 = select_where(longer, shorter, false);
+///     res = select_where(longer, shorter, false);
 /// }
-/// assert_eq!(res1, &outer);
-/// assert_eq!(res2, &outer);
+/// assert_eq!(res, &outer);
 /// ```
 ///
 /// `where` can also be used to express more complicated constraints that cannot
@@ -1771,12 +1748,11 @@ mod use_keyword {}
 /// assert_eq!(first_or_default(Vec::<i32>::new().into_iter()), 0);
 /// ```
 ///
-/// `where` is available anywhere generic and lifetime parameters are available:
+/// `where` is available anywhere generic and lifetime parameters are available,
+/// as can be seen in the [`Cow`](crate::borrow::Cow) from the standard library:
 ///
 /// ```rust
 /// # #![allow(dead_code)]
-/// // The Cow type from the standard library uses where to impose constraints
-/// // on its parameters.
 /// pub enum Cow<'a, B>
 /// where
 ///     B: 'a + ToOwned + ?Sized,