From bc98e9fbc239d335c33fc1751125f1212c47f8ef Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Mon, 2 Mar 2015 18:01:01 +0800 Subject: [PATCH] str: fix comments for FromStr for bool Fix the return type in the comments. An old commit 082bfde41217 ("Fallout of std::str stabilization") removed the example of FromStr::from_str(), this commit adds it back. But the example of StrExt::parse() is still kept with an additinal note. Signed-off-by: Lai Jiangshan --- src/libcore/str/mod.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index b354116993c..21c6c846576 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -134,12 +134,23 @@ impl FromStr for bool { /// Parse a `bool` from a string. /// - /// Yields an `Option`, because `s` may or may not actually be - /// parseable. + /// Yields a `Result`, because `s` may or may not + /// actually be parseable. /// /// # Examples /// /// ```rust + /// use std::str::FromStr; + /// + /// assert_eq!(FromStr::from_str("true"), Ok(true)); + /// assert_eq!(FromStr::from_str("false"), Ok(false)); + /// assert!(::from_str("not even a boolean").is_err()); + /// ``` + /// + /// Note, in many cases, the StrExt::parse() which is based on + /// this FromStr::from_str() is more proper. + /// + /// ```rust /// assert_eq!("true".parse(), Ok(true)); /// assert_eq!("false".parse(), Ok(false)); /// assert!("not even a boolean".parse::().is_err());