diff options
| author | bors <bors@rust-lang.org> | 2013-09-08 12:05:55 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-09-08 12:05:55 -0700 |
| commit | dd5c7379e9b8f3fe6df95f3ff43ca955b6bba485 (patch) | |
| tree | 50215436ea9ba30936847af7969882af83485b3e | |
| parent | d36612d65b67e18c7f8d247055f83b28a602e875 (diff) | |
| parent | e0e5523552c5b7ae6c7175c5e7aeefbac5fd0ba1 (diff) | |
| download | rust-dd5c7379e9b8f3fe6df95f3ff43ca955b6bba485.tar.gz rust-dd5c7379e9b8f3fe6df95f3ff43ca955b6bba485.zip | |
auto merge of #8988 : cmr/rust/fromstr_fn, r=brson
It just calls out to the associated function on the trait.
| -rw-r--r-- | src/libstd/from_str.rs | 5 | ||||
| -rw-r--r-- | src/libstd/num/float.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/prelude.rs | 1 |
5 files changed, 9 insertions, 3 deletions
diff --git a/src/libstd/from_str.rs b/src/libstd/from_str.rs index d2f1a895e1e..e5bf9f6bb2a 100644 --- a/src/libstd/from_str.rs +++ b/src/libstd/from_str.rs @@ -19,3 +19,8 @@ pub trait FromStr { /// string is ill-formatted, the None is returned. fn from_str(s: &str) -> Option<Self>; } + +/// A utility function that just calls FromStr::from_str +pub fn from_str<A: FromStr>(s: &str) -> Option<A> { + FromStr::from_str(s) +} diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 4dd6fd25333..df26fadae16 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -946,8 +946,8 @@ impl Float for float { #[cfg(test)] mod tests { - use super::*; use prelude::*; + use super::*; use num::*; use num; diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 377d0a78134..07cafb0a4f1 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -547,8 +547,8 @@ impl ToStrRadix for $T { #[cfg(test)] mod tests { - use super::*; use prelude::*; + use super::*; use int; use i16; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index af991045b45..effeb60fc22 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -430,8 +430,8 @@ impl BitCount for $T { #[cfg(test)] mod tests { - use super::*; use prelude::*; + use super::*; use num; use sys; 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; |
