Skip to content

Commit d36d3fa

Browse files
committed
fixes to Option::{zip,zip_with}
- remove `#[inline]` attributes (see #69997 (comment)) - fill tracking issue in `#[unstable]` attributes - slightly improve the docs
1 parent a5206f9 commit d36d3fa

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/libcore/option.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ impl<T> Option<T> {
916916

917917
/// Zips `self` with another `Option`.
918918
///
919-
/// Returns `Some((_, _))` when both `self` and `other`
920-
/// are `Some(_)`, otherwise return `None`.
919+
/// If `self` is `Some(s)` and other is `Some(o)`, this method returns `Some((s, o))`.
920+
/// Otherwise, `None` is returned.
921921
///
922922
/// # Examples
923923
///
@@ -930,16 +930,15 @@ impl<T> Option<T> {
930930
/// assert_eq!(x.zip(y), Some((1, "hi")));
931931
/// assert_eq!(x.zip(z), None);
932932
/// ```
933-
#[inline]
934-
#[unstable(feature = "option_zip", issue = "none")]
933+
#[unstable(feature = "option_zip", issue = "70086")]
935934
pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
936935
self.zip_with(other, |a, b| (a, b))
937936
}
938937

939938
/// Zips `self` and another `Option` with function `f`.
940939
///
941-
/// Returns `Some(_)` when both `self` and `other`
942-
/// are `Some(_)`, otherwise return `None`.
940+
/// If `self` is `Some(s)` and other is `Some(o)`, this method returns `Some(f(s, o))`.
941+
/// Otherwise, `None` is returned.
943942
///
944943
/// # Examples
945944
///
@@ -958,14 +957,13 @@ impl<T> Option<T> {
958957
/// }
959958
/// }
960959
///
961-
/// let x = Some(17.);
962-
/// let y = Some(42.);
960+
/// let x = Some(17.5);
961+
/// let y = Some(42.7);
963962
///
964-
/// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17., y: 42. }));
963+
/// assert_eq!(x.zip_with(y, Point::new), Some(Point { x: 17.5, y: 42.7 }));
965964
/// assert_eq!(x.zip_with(None, Point::new), None);
966965
/// ```
967-
#[inline]
968-
#[unstable(feature = "option_zip", issue = "none")]
966+
#[unstable(feature = "option_zip", issue = "70086")]
969967
pub fn zip_with<U, F, R>(self, other: Option<U>, f: F) -> Option<R>
970968
where
971969
F: FnOnce(T, U) -> R,

0 commit comments

Comments
 (0)