Add docs for Missing, correct Option's Try test

This commit is contained in:
Hunter Praska 2017-06-08 14:02:04 -05:00 committed by Niko Matsakis
parent f098d7be29
commit 8f63e8de46
2 changed files with 3 additions and 3 deletions

View file

@ -1124,7 +1124,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
}
}
/// The `Option` type. See [the module level documentation](index.html) for more.
/// The equivalent of `Option::None` for a `Result::Err`.
#[unstable(feature = "try_trait", issue = "42327")]
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
pub struct Missing;

View file

@ -286,13 +286,13 @@ fn test_try() {
assert_eq!(try_option_none(), None);
fn try_option_ok() -> Result<u8, Missing> {
let val = Ok(1)?;
let val = Some(1)?;
Ok(val)
}
assert_eq!(try_option_ok(), Ok(1));
fn try_option_err() -> Result<u8, Missing> {
let val = Err(Missing)?;
let val = None?;
Ok(val)
}
assert_eq!(try_option_err(), Err(Missing));