mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Add a from_str function that calls out to the associated method on the trait
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user