about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2013-09-05 00:48:48 -0400
committerCorey Richardson <corey@octayn.net>2013-09-05 00:48:48 -0400
commitbe43625082bf14f7ca49c9edc4b8a899fd73eddf (patch)
tree5b56a567af6973c9f50e4a4f4b9b88c92ab5616a
parentb6d825ee567633d917127a91a3f8a98012a24170 (diff)
downloadrust-be43625082bf14f7ca49c9edc4b8a899fd73eddf.tar.gz
rust-be43625082bf14f7ca49c9edc4b8a899fd73eddf.zip
Add a from_str function that calls out to the associated method on the trait
-rw-r--r--src/libstd/from_str.rs4
-rw-r--r--src/libstd/prelude.rs1
2 files changed, 5 insertions, 0 deletions
diff --git a/src/libstd/from_str.rs b/src/libstd/from_str.rs
index d2f1a895e1e..a2417ae70cc 100644
--- a/src/libstd/from_str.rs
+++ b/src/libstd/from_str.rs
@@ -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)
+}
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index 8f202ee8531..9cdf7af091f 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -41,6 +41,7 @@ pub use result::{Result, Ok, Err};
 // 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;