File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Expand file tree Collapse file tree 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> {
834834 ///
835835 /// # Examples
836836 ///
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- ///
842837 /// ```
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);
848840 ///
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 );
851843 /// ```
852844 ///
853845 /// [default value]: Default::default
You can’t perform that action at this time.
0 commit comments