File tree 1 file changed +4
-12
lines changed
1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -834,20 +834,12 @@ impl<T> Option<T> {
834
834
///
835
835
/// # Examples
836
836
///
837
- /// Converts a string to an integer, turning poorly-formed strings
838
- /// into 0 (the default value for integers). [`parse`] converts
839
- /// a string to any other type that implements [`FromStr`], returning
840
- /// [`None`] on error.
841
- ///
842
837
/// ```
843
- /// let good_year_from_input = "1909";
844
- /// let bad_year_from_input = "190blarg";
845
- /// // Result::ok() converts a Result<T> to an Option<T>
846
- /// let good_year = good_year_from_input.parse().ok().unwrap_or_default();
847
- /// let bad_year = bad_year_from_input.parse().ok().unwrap_or_default();
838
+ /// let x: Option<u32> = None;
839
+ /// let y: Option<u32> = Some(12);
848
840
///
849
- /// assert_eq!(1909, good_year );
850
- /// assert_eq!(0, bad_year );
841
+ /// assert_eq!(x.unwrap_or_default(), 0 );
842
+ /// assert_eq!(y.unwrap_or_default(), 12 );
851
843
/// ```
852
844
///
853
845
/// [default value]: Default::default
You can’t perform that action at this time.
0 commit comments