diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-09 23:10:50 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-10 23:02:54 +1000 |
| commit | 1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46 (patch) | |
| tree | 54f03a318e14bcdbdb56e01b3c80d00a9db87a17 /src/libextra/num | |
| parent | 2ff6b298c5f23f48aa993fced41b6e29e446b7ce (diff) | |
| download | rust-1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46.tar.gz rust-1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46.zip | |
std: replace str::each_split* with an iterator
Diffstat (limited to 'src/libextra/num')
| -rw-r--r-- | src/libextra/num/rational.rs | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs index 1a8ab75b3dd..08fbb8aacc9 100644 --- a/src/libextra/num/rational.rs +++ b/src/libextra/num/rational.rs @@ -12,11 +12,10 @@ use core::prelude::*; +use core::iterator::IteratorUtil; use core::cmp; use core::from_str::FromStr; use core::num::{Zero,One,ToStrRadix,FromStrRadix,Round}; -use core::str; -use core::vec; use super::bigint::BigInt; /// Represents the ratio between 2 numbers. @@ -252,11 +251,7 @@ impl<T: FromStr + Clone + Integer + Ord> FromStr for Ratio<T> { /// Parses `numer/denom`. fn from_str(s: &str) -> Option<Ratio<T>> { - let split = vec::build(|push| { - for str::each_splitn_char(s, '/', 1) |s| { - push(s.to_owned()); - } - }); + let split: ~[&str] = s.splitn_iter('/', 1).collect(); if split.len() < 2 { return None; } do FromStr::from_str::<T>(split[0]).chain |a| { do FromStr::from_str::<T>(split[1]).chain |b| { @@ -269,11 +264,7 @@ impl<T: FromStrRadix + Clone + Integer + Ord> FromStrRadix for Ratio<T> { /// Parses `numer/denom` where the numbers are in base `radix`. fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>> { - let split = vec::build(|push| { - for str::each_splitn_char(s, '/', 1) |s| { - push(s.to_owned()); - } - }); + let split: ~[&str] = s.splitn_iter('/', 1).collect(); if split.len() < 2 { None } else { do FromStrRadix::from_str_radix::<T>(split[0], radix).chain |a| { |
