diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 982cb272b..2a8092fe5 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -23,19 +23,19 @@ impl std::str::FromStr for Range { match (parts.next(), parts.next()) { (Some(nm), None) => { - from_str::(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) + std::str::FromStr::from_str::(nm).and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) } (Some(n), Some(m)) if m.len() == 0 => { - from_str::(n).and_then(|low| if low > 0 { Some(low) } else { None }) + std::str::FromStr::from_str::(n).and_then(|low| if low > 0 { Some(low) } else { None }) .map(|low| Range { low: low, high: MAX }) } (Some(n), Some(m)) if n.len() == 0 => { - from_str::(m).and_then(|high| if high >= 1 { Some(high) } else { None }) + std::str::FromStr::from_str::(m).and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) } (Some(n), Some(m)) => { - match (from_str::(n), from_str::(m)) { + match (std::str::FromStr::from_str::(n), std::str::FromStr::from_str::(m)) { (Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } @@ -54,7 +54,7 @@ impl Range { let mut ranges = vec!(); for item in list.split(',') { - match from_str::(item) { + match std::str::FromStr::from_str(item) { Some(range_item) => ranges.push(range_item), None => return Err(format!("range '{}' was invalid", item)) } diff --git a/src/expand/expand.rs b/src/expand/expand.rs index b0b922d39..6ba026e92 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -13,7 +13,7 @@ extern crate getopts; extern crate libc; use std::io; -use std::str::from_str; +use std::str::StrExt; #[path = "../common/util.rs"] #[macro_use] @@ -28,7 +28,7 @@ fn tabstops_parse(s: String) -> Vec { let words = s.as_slice().split(',').collect::>(); let nums = words.into_iter() - .map(|sn| from_str::(sn) + .map(|sn| sn.parse::() .unwrap_or_else( || crash!(1, "{}\n", "tab size contains invalid character(s)")) ) diff --git a/src/factor/factor.rs b/src/factor/factor.rs index 5a3c31de0..935c1c645 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -56,7 +56,7 @@ fn print_factors(num: u64) { } fn print_factors_str(num_str: &str) { - let num = match from_str(num_str) { + let num = match num_str.parse::() { Some(x) => x, None => { crash!(1, "{} not a number", num_str); } }; diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 6168273a0..db5dd748b 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -140,7 +140,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("w") { Some(s) => { fmt_opts.width = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid WIDTH specification: `{}'", s); } }; @@ -152,7 +152,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("g") { Some(s) => { fmt_opts.goal = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid GOAL specification: `{}'", s); } }; @@ -168,7 +168,7 @@ pub fn uumain(args: Vec) -> int { match matches.opt_str("T") { Some(s) => { fmt_opts.tabwidth = - match from_str(s.as_slice()) { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); } }; diff --git a/src/fold/fold.rs b/src/fold/fold.rs index b66fcb674..721a31203 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -62,7 +62,7 @@ pub fn uumain(args: Vec) -> int { } }; let width = match poss_width { - Some(inp_width) => match from_str(inp_width.as_slice()) { + Some(inp_width) => match inp_width.parse::() { Some(width) => width, None => crash!(1, "illegal width value (\"{}\")", inp_width) }, diff --git a/src/head/head.rs b/src/head/head.rs index af0382c2f..5ff853df9 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -68,7 +68,7 @@ pub fn uumain(args: Vec) -> int { show_error!("cannot specify both --bytes and --lines."); return 1; } - match from_str(n.as_slice()) { + match n.parse::() { Some(m) => { line_count = m } None => { show_error!("invalid line count '{}'", n); @@ -77,7 +77,7 @@ pub fn uumain(args: Vec) -> int { } } None => match given_options.opt_str("c") { - Some(count) => match from_str(count.as_slice()) { + Some(count) => match count.parse::() { Some(m) => byte_count = m, None => { show_error!("invalid byte count '{}'", count); @@ -149,7 +149,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_str(from_utf8(current.slice(1,len)).unwrap()); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); return (options, Some(number.unwrap())); } } diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index f90ae46e2..589165288 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -52,7 +52,7 @@ pub fn uumain(args: Vec) -> int { } let mut ignore = match matches.opt_str("ignore") { - Some(numstr) => match from_str(numstr.as_slice()) { + Some(numstr) => match numstr.parse() { Some(num) => num, None => { show_error!("\"{}\" is not a valid number", numstr); @@ -64,7 +64,7 @@ pub fn uumain(args: Vec) -> int { if !matches.opt_present("all") { ignore += match os::getenv("OMP_NUM_THREADS") { - Some(threadstr) => match from_str(threadstr.as_slice()) { + Some(threadstr) => match threadstr.parse() { Some(num) => num, None => 0 }, diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 18c9ea066..fc7489413 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -13,7 +13,6 @@ extern crate getopts; extern crate libc; use std::cmp; -use std::str::from_str; use std::io; use std::io::IoResult; use std::iter::{range_inclusive, RangeInclusive}; @@ -96,7 +95,7 @@ With no FILE, or when FILE is -, read standard input.", let repeat = matches.opt_present("repeat"); let zero = matches.opt_present("zero-terminated"); let count = match matches.opt_str("head-count") { - Some(cnt) => match from_str::(cnt.as_slice()) { + Some(cnt) => match cnt.parse::() { Some(val) => val, None => { show_error!("'{}' is not a valid count", cnt); @@ -191,11 +190,11 @@ fn parse_range(input_range: String) -> Result, (String, int if split.len() != 2 { Err(("invalid range format".to_string(), 1)) } else { - let begin = match from_str::(split[0]) { + let begin = match split[0].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[0]), 1)) }; - let end = match from_str::(split[1]) { + let end = match split[1].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[1]), 1)) }; diff --git a/src/tail/tail.rs b/src/tail/tail.rs index b09f98cd5..19b637abe 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -71,7 +71,7 @@ pub fn uumain(args: Vec) -> int { if follow { match given_options.opt_str("s") { Some(n) => { - let parsed: Option = from_str(n.as_slice()); + let parsed: Option = n.parse(); match parsed { Some(m) => { sleep_msec = m * 1000 } None => {} @@ -192,7 +192,7 @@ fn parse_size(mut size_slice: &str) -> Option { // sole B is not a valid suffix None } else { - let value = from_str(size_slice); + let value = size_slice.parse(); match value { Some(v) => Some(multiplier * v), None => None @@ -222,7 +222,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_str(from_utf8(current.slice(1,len)).unwrap()); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); return (options, Some(number.unwrap())); } } diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index bc4642f4c..626246bef 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -111,7 +111,7 @@ impl Uniq { fn opt_parsed(opt_name: &str, matches: &getopts::Matches) -> Option { matches.opt_str(opt_name).map(|arg_str| { - let opt_val: Option = from_str(arg_str.as_slice()); + let opt_val: Option = arg_str.parse(); opt_val.unwrap_or_else(|| crash!(1, "Invalid argument for {}: {}", opt_name, arg_str)) })