Add docs for Missing, correct Option's Try test
This commit is contained in:
parent
f098d7be29
commit
8f63e8de46
2 changed files with 3 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue