Add a from_str function that calls out to the associated method on the trait

This commit is contained in:
Corey Richardson
2013-09-05 00:48:48 -04:00
parent b6d825ee56
commit be43625082
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -19,3 +19,7 @@ pub trait FromStr {
/// string is ill-formatted, the None is returned.
fn from_str(s: &str) -> Option<Self>;
}
pub fn from_str<A: FromStr>(s: &str) -> Option<A> {
FromStr::from_str(s)
}
+1
View File
@@ -41,6 +41,7 @@
// Reexported functions
pub use io::{print, println};
pub use iterator::range;
pub use from_str::from_str;
// Reexported types and traits
pub use c_str::ToCStr;