From 2a5a6b42ecf99b198eae89e13053b00bd1582a27 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 15 Sep 2020 18:18:04 +0200 Subject: [PATCH] Add missing code examples in libcore --- library/core/src/num/dec2flt/mod.rs | 10 ++++++++++ library/core/src/num/mod.rs | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index ed6202bb82f..6f3a3a86745 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -166,6 +166,16 @@ fn from_str(src: &str) -> Result { /// /// This error is used as the error type for the [`FromStr`] implementation /// for [`f32`] and [`f64`]. +/// +/// # Example +/// +/// ``` +/// use std::str::FromStr; +/// +/// if let Err(e) = f64::from_str("a.12") { +/// println!("Failed conversion to f64: {}", e); +/// } +/// ``` #[derive(Debug, Clone, PartialEq, Eq)] #[stable(feature = "rust1", since = "1.0.0")] pub struct ParseFloatError { diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 2a936c1867d..050c187e555 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -5286,6 +5286,14 @@ fn from_str_radix(src: &str, radix: u32) -> Result