mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Make Result
's unwrap_or_default
unstable
This commit is contained in:
parent
1c2151b7f9
commit
fb1ef4f42c
@ -802,8 +802,8 @@ impl<T: Default, E> Result<T, E> {
|
||||
/// # Examples
|
||||
///
|
||||
/// Convert a string to an integer, turning poorly-formed strings
|
||||
/// into 0 (the default value for integers). `parse` converts
|
||||
/// a string to any other type that implements `FromStr`, returning an
|
||||
/// into 0 (the default value for integers). [`parse`] converts
|
||||
/// a string to any other type that implements [`FromStr`], returning an
|
||||
/// `Err` on error.
|
||||
///
|
||||
/// ```
|
||||
@ -814,9 +814,12 @@ impl<T: Default, E> Result<T, E> {
|
||||
///
|
||||
/// assert_eq!(1909, good_year);
|
||||
/// assert_eq!(0, bad_year);
|
||||
///
|
||||
/// [`parse`]: ../../std/primitive.str.html#method.parse
|
||||
/// [`FromStr`]: ../../std/str/trait.FromStr.html
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[unstable(feature = "result_unwrap_or_default", issue = "0")]
|
||||
pub fn unwrap_or_default(self) -> T {
|
||||
match self {
|
||||
Ok(x) => x,
|
||||
|
Loading…
Reference in New Issue
Block a user