Skip to content

Commit 854c81c

Browse files
authored
Rollup merge of rust-lang#40999 - irfanhudda:improve-option-docs, r=steveklabnik
Improve option API docs Associated Issue: rust-lang#29366 Improve `option` API docs for * `IntoIter` struct * `Iter` struct * `IterMut` struct r? @steveklabnik
2 parents 800b85e + 4c9f8ae commit 854c81c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/libcore/option.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -894,9 +894,15 @@ impl<A> ExactSizeIterator for Item<A> {}
894894
impl<A> FusedIterator for Item<A> {}
895895
unsafe impl<A> TrustedLen for Item<A> {}
896896

897-
/// An iterator over a reference of the contained item in an [`Option`].
897+
/// An iterator over a reference to the [`Some`] variant of an [`Option`].
898+
///
899+
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
900+
///
901+
/// This `struct` is created by the [`Option::iter`] function.
898902
///
899903
/// [`Option`]: enum.Option.html
904+
/// [`Some`]: enum.Option.html#variant.Some
905+
/// [`Option::iter`]: enum.Option.html#method.iter
900906
#[stable(feature = "rust1", since = "1.0.0")]
901907
#[derive(Debug)]
902908
pub struct Iter<'a, A: 'a> { inner: Item<&'a A> }
@@ -933,9 +939,15 @@ impl<'a, A> Clone for Iter<'a, A> {
933939
}
934940
}
935941

936-
/// An iterator over a mutable reference of the contained item in an [`Option`].
942+
/// An iterator over a mutable reference to the [`Some`] variant of an [`Option`].
943+
///
944+
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
945+
///
946+
/// This `struct` is created by the [`Option::iter_mut`] function.
937947
///
938948
/// [`Option`]: enum.Option.html
949+
/// [`Some`]: enum.Option.html#variant.Some
950+
/// [`Option::iter_mut`]: enum.Option.html#method.iter_mut
939951
#[stable(feature = "rust1", since = "1.0.0")]
940952
#[derive(Debug)]
941953
pub struct IterMut<'a, A: 'a> { inner: Item<&'a mut A> }
@@ -964,9 +976,15 @@ impl<'a, A> FusedIterator for IterMut<'a, A> {}
964976
#[unstable(feature = "trusted_len", issue = "37572")]
965977
unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {}
966978

967-
/// An iterator over the item contained inside an [`Option`].
979+
/// An iterator over the value in [`Some`] variant of an [`Option`].
980+
///
981+
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
982+
///
983+
/// This `struct` is created by the [`Option::into_iter`] function.
968984
///
969985
/// [`Option`]: enum.Option.html
986+
/// [`Some`]: enum.Option.html#variant.Some
987+
/// [`Option::into_iter`]: enum.Option.html#method.into_iter
970988
#[derive(Clone, Debug)]
971989
#[stable(feature = "rust1", since = "1.0.0")]
972990
pub struct IntoIter<A> { inner: Item<A> }

0 commit comments

Comments
 (0)