From d14216836512fc57a151edfecb570f14437dbc87 Mon Sep 17 00:00:00 2001 From: Santiago Lapresta Date: Thu, 25 Dec 2014 19:55:32 +0100 Subject: [PATCH] Fix deprecation warnings on latest nightlies --- mkmain.rs | 3 +-- src/mv/mv.rs | 5 +++-- src/nl/helper.rs | 8 ++++---- src/seq/seq.rs | 2 +- src/test/test.rs | 4 ++-- src/truncate/truncate.rs | 2 +- src/unexpand/unexpand.rs | 4 +--- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/mkmain.rs b/mkmain.rs index 7117cc191..34a0abbad 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,7 +1,6 @@ use std::io::{File, Truncate, ReadWrite}; use std::os; use std::path::Path; -use std::str::replace; static TEMPLATE: &'static str = "\ extern crate @UTIL_CRATE@; @@ -31,7 +30,7 @@ fn main() { }; let outfile = args[2].as_slice(); - let main = std::str::replace(TEMPLATE, "@UTIL_CRATE@", crat); + let main = TEMPLATE.replace("@UTIL_CRATE@", crat); let mut out = File::open_mode(&Path::new(outfile), Truncate, ReadWrite); match out.write(main.as_bytes()) { diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 4b5bc0b84..526b2865a 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -25,6 +25,7 @@ use getopts::{ optopt, usage, }; +use std::borrow::ToOwned; #[path = "../common/util.rs"] mod util; @@ -142,7 +143,7 @@ pub fn uumain(args: Vec) -> int { } } } else { - "~".into_string() + "~".to_owned() }; if matches.opt_present("T") && matches.opt_present("t") { @@ -347,7 +348,7 @@ fn numbered_backup_path(path: &Path) -> Path { } fn existing_backup_path(path: &Path, suffix: &String) -> Path { - let test_path = simple_backup_path(path, &".~1~".into_string()); + let test_path = simple_backup_path(path, &".~1~".to_owned()); if test_path.exists() { return numbered_backup_path(path); } diff --git a/src/nl/helper.rs b/src/nl/helper.rs index d627e325f..c68a5d4f6 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -71,7 +71,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("i") { None => {} Some(val) => { - let conv: Option = from_str(val.as_slice()); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -i")); @@ -83,7 +83,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("w") { None => {} Some(val) => { - let conv: Option = from_str(val.as_slice()); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -w")); @@ -95,7 +95,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("v") { None => {} Some(val) => { - let conv: Option = from_str(val.as_slice()); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -v")); @@ -107,7 +107,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("l") { None => {} Some(val) => { - let conv: Option = from_str(val.as_slice()); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -l")); diff --git a/src/seq/seq.rs b/src/seq/seq.rs index b7986c31b..a396b0ec2 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -26,7 +26,7 @@ fn parse_float(mut s: &str) -> Result { if s.starts_with("+") { s = s.slice_from(1); } - match from_str(s) { + match s.parse() { Some(n) => Ok(n), None => Err(format!("seq: invalid floating point argument: {}", s)) } diff --git a/src/test/test.rs b/src/test/test.rs index ea41e643d..0b0c2ad8a 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -124,7 +124,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool { (Ok(a), Ok(b)) => (a, b), _ => return false, }; - let (a, b): (i64, i64) = match (from_str(a), from_str(b)) { + let (a, b): (i64, i64) = match (a.parse(), b.parse()) { (Some(a), Some(b)) => (a, b), _ => return false, }; @@ -140,7 +140,7 @@ fn integers(a: &[u8], b: &[u8], cond: IntegerCondition) -> bool { fn isatty(fd: &[u8]) -> bool { use libc::{isatty}; - from_utf8(fd).ok().and_then(|s| from_str(s)) + from_utf8(fd).ok().and_then(|s| s.parse()) .map(|i| unsafe { isatty(i) == 1 }).unwrap_or(false) } diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 2cc6983d8..cc071ebb2 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -184,7 +184,7 @@ fn parse_size(size: &str) -> (u64, TruncateMode) { } slice }.to_string(); - let mut number = match from_str::(bytes.as_slice()) { + let mut number: u64 = match bytes.as_slice().parse() { Some(num) => num, None => { crash!(1, "'{}' is not a valid number.", size) diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index 8ae3c14a9..58deef87a 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -15,7 +15,6 @@ extern crate getopts; extern crate libc; use std::io; -use std::str::from_str; #[path = "../common/util.rs"] mod util; @@ -29,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)")) ) @@ -225,4 +224,3 @@ fn unexpand(options: Options) { } } } -