]> git.lizzy.rs Git - rust.git/commitdiff
fixes to `Option::{zip,zip_with}`
authorWaffle <waffle.lapkin@gmail.com>
Wed, 18 Mar 2020 08:02:29 +0000 (11:02 +0300)
committerWaffle <waffle.lapkin@gmail.com>
Wed, 18 Mar 2020 08:26:04 +0000 (11:26 +0300)
- remove `#[inline]` attributes (see https://github.com/rust-lang/rust/pull/69997#discussion_r393942617)
- fill tracking issue in `#[unstable]` attributes
- slightly improve the docs

src/libcore/option.rs

index 5db92a1b35248e65030d1b767af7e92f8fbaf559..4bec3ec9f6b423aa1239653cadcc482a1ae58cb0 100644 (file)
@@ -916,8 +916,8 @@ pub fn replace(&mut self, value: T) -> Option<T> {
 
     /// Zips `self` with another `Option`.
     ///
-    /// Returns `Some((_, _))` when both `self` and `other`
-    /// are `Some(_)`, otherwise return `None`.
+    /// If `self` is `Some(s)` and other is `Some(o)`, this method returns `Some((s, o))`.
+    /// Otherwise, `None` is returned.
     ///
     /// # Examples
     ///
@@ -930,16 +930,15 @@ pub fn replace(&mut self, value: T) -> Option<T> {
     /// assert_eq!(x.zip(y), Some((1, "hi")));
     /// assert_eq!(x.zip(z), None);
     /// ```
-    #[inline]
-    #[unstable(feature = "option_zip", issue = "none")]
+    #[unstable(feature = "option_zip", issue = "70086")]
     pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
         self.zip_with(other, |a, b| (a, b))
     }
 
     /// Zips `self` and another `Option` with function `f`.
     ///
-    /// Returns `Some(_)` when both `self` and `other`
-    /// are `Some(_)`, otherwise return `None`.
+    /// If `self` is `Some(s)` and other is `Some(o)`, this method returns `Some(f(s, o))`.
+    /// Otherwise, `None` is returned.
     ///
     /// # Examples
     ///
@@ -958,14 +957,13 @@ pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
     ///     }
     /// }
     ///
-    /// let x = Some(17.);
-    /// let y = Some(42.);
+    /// let x = Some(17.5);
+    /// let y = Some(42.7);
     ///
-    /// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17., y: 42. }));
+    /// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));
     /// assert_eq!(x.zip_with(None, Point::new), None);
     /// ```
-    #[inline]
-    #[unstable(feature = "option_zip", issue = "none")]
+    #[unstable(feature = "option_zip", issue = "70086")]
     pub fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
     where
         F: FnOnce(T, U) -> R,