Skip to content

Commit be43625

Browse files
committed
Add a from_str function that calls out to the associated method on the trait
1 parent b6d825e commit be43625

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/libstd/from_str.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ pub trait FromStr {
1919
/// string is ill-formatted, the None is returned.
2020
fn from_str(s: &str) -> Option<Self>;
2121
}
22+
23+
pub fn from_str<A: FromStr>(s: &str) -> Option<A> {
24+
FromStr::from_str(s)
25+
}

src/libstd/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub use result::{Result, Ok, Err};
4141
// Reexported functions
4242
pub use io::{print, println};
4343
pub use iterator::range;
44+
pub use from_str::from_str;
4445

4546
// Reexported types and traits
4647
pub use c_str::ToCStr;

0 commit comments

Comments
 (0)