From 605c1072585ba2d67c836c8326865521dac1a457 Mon Sep 17 00:00:00 2001 From: Stephan Jaensch Date: Thu, 1 Jan 2015 12:14:28 +0100 Subject: [PATCH] Fix deprecation warnings with latest rust nightly - from_str() -> parse() - into_string() -> to_owned() --- src/base64/base64.rs | 2 +- src/basename/basename.rs | 7 ++++--- src/common/c_types.rs | 4 ++-- src/common/time.rs | 2 +- src/kill/kill.rs | 5 ++--- src/nice/nice.rs | 2 +- src/tty/tty.rs | 2 +- src/uptime/uptime.rs | 3 +-- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/base64/base64.rs b/src/base64/base64.rs index f4e04ad18..06f62e5e5 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -66,7 +66,7 @@ pub fn uumain(args: Vec) -> int { }; let ignore_garbage = matches.opt_present("ignore-garbage"); let line_wrap = match matches.opt_str("wrap") { - Some(s) => match from_str(s.as_slice()) { + Some(s) => match s.parse() { Some(s) => s, None => { error!("error: {}", "Argument to option 'wrap' improperly formatted."); diff --git a/src/basename/basename.rs b/src/basename/basename.rs index d6ccd6a61..d2b44ac0d 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -13,6 +13,7 @@ extern crate getopts; extern crate libc; +use std::borrow::ToOwned; use std::io::{print, println}; #[path = "../common/util.rs"] @@ -99,12 +100,12 @@ fn strip_dir(fullname: &str) -> String { fn strip_suffix(name: &str, suffix: &str) -> String { if name == suffix { - return name.into_string(); + return name.to_owned(); } if name.ends_with(suffix) { - return name.slice_to(name.len() - suffix.len()).into_string(); + return name.slice_to(name.len() - suffix.len()).to_owned(); } - name.into_string() + name.to_owned() } diff --git a/src/common/c_types.rs b/src/common/c_types.rs index ea4818b7c..1f653dc63 100644 --- a/src/common/c_types.rs +++ b/src/common/c_types.rs @@ -119,7 +119,7 @@ pub fn get_pw_from_args(free: &Vec) -> Option { // Passed user as id if username.chars().all(|c| c.is_digit(10)) { - let id = from_str::(username).unwrap(); + let id = username.parse::().unwrap(); let pw_pointer = unsafe { getpwuid(id as uid_t) }; if pw_pointer.is_not_null() { @@ -146,7 +146,7 @@ pub fn get_pw_from_args(free: &Vec) -> Option { pub fn get_group(groupname: &str) -> Option { let group = if groupname.chars().all(|c| c.is_digit(10)) { - unsafe { getgrgid(from_str::(groupname).unwrap()) } + unsafe { getgrgid(groupname.parse().unwrap()) } } else { unsafe { getgrnam(groupname.to_c_str().into_inner() as *const c_char) } }; diff --git a/src/common/time.rs b/src/common/time.rs index 417598ef6..a85f43900 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -28,7 +28,7 @@ pub fn from_str(string: &str) -> Result { } } }; - match ::std::str::from_str::(numstr) { + match numstr.parse::() { Some(m) => Ok(m * times as f64), None => Err(format!("invalid time interval '{}'", string)) } diff --git a/src/kill/kill.rs b/src/kill/kill.rs index cec00d0b0..379fa4e5e 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -19,7 +19,6 @@ extern crate serialize; #[phase(plugin, link)] extern crate log; -use std::str::from_str; use std::io::process::Process; use getopts::{ @@ -109,7 +108,7 @@ fn handle_obsolete(mut args: Vec) -> (Vec, Option) { let slice: &str = unsafe { std::mem::transmute(args[i].as_slice()) }; if slice.char_at(0) == '-' && slice.len() > 1 && slice.char_at(1).is_digit(10) { let val = slice.slice_from(1); - match from_str(val) { + match val.parse() { Some(num) => { if signals::is_signal(num) { args.remove(i); @@ -194,7 +193,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> int { None => crash!(EXIT_ERR, "unknown signal name {}", signalname) }; for pid in pids.iter() { - match from_str::(pid.as_slice()) { + match pid.as_slice().parse() { Some(x) => { let result = Process::kill(x, signal_value as int); match result { diff --git a/src/nice/nice.rs b/src/nice/nice.rs index e539bc729..a2069ed58 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -79,7 +79,7 @@ pub fn uumain(args: Vec) -> int { Try \"{} --help\" for more information.", args[0]); return 125; } - match from_str(nstr.as_slice()) { + match nstr.as_slice().parse() { Some(num) => num, None => { show_error!("\"{}\" is not a valid number", nstr); diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 4b63c88f4..219456087 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -52,7 +52,7 @@ pub fn uumain(args: Vec) -> int { let tty = unsafe { String::from_raw_buf(ttyname(libc::STDIN_FILENO) as *const u8) }; if !silent { - if !tty.as_slice().is_whitespace() { + if !tty.as_slice().chars().all(|c| c.is_whitespace()) { println(tty.as_slice()); } else { println!("not a tty"); diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 3ddaa0838..2bc30317d 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -21,7 +21,6 @@ extern crate "time" as rtime; use std::mem::transmute; use std::io::{print, File}; use std::ptr::null; -use std::str::from_str; use libc::{time_t, c_double, c_int, c_char}; use utmpx::*; @@ -182,7 +181,7 @@ fn get_uptime(boot_time: Option) -> i64 { }; match uptime_text.as_slice().words().next() { - Some(s) => match from_str(s.replace(".", "").as_slice()) { + Some(s) => match s.replace(".", "").as_slice().parse() { Some(n) => n, None => -1 },