From 98039f176d8fc392dbc9e6dbb96412cbb6009f98 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 26 Dec 2019 10:58:50 -0600 Subject: [PATCH] refactor/polish ~ fix `cargo clippy` complaints (String => str) --- src/pathchk/pathchk.rs | 6 +++--- src/printf/memo.rs | 2 +- src/printf/tokenize/num_format/num_format.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pathchk/pathchk.rs b/src/pathchk/pathchk.rs index 25a73ba68..83d30f5d2 100644 --- a/src/pathchk/pathchk.rs +++ b/src/pathchk/pathchk.rs @@ -229,7 +229,7 @@ fn check_default(path: &[String]) -> bool { } // check whether a path is or if other problems arise -fn check_searchable(path: &String) -> bool { +fn check_searchable(path: &str) -> bool { // we use lstat, just like the original implementation match fs::symlink_metadata(path) { Ok(_) => true, @@ -243,12 +243,12 @@ fn check_searchable(path: &String) -> bool { } // check for a hyphen at the beginning of a path segment -fn no_leading_hyphen(path_segment: &String) -> bool { +fn no_leading_hyphen(path_segment: &str) -> bool { !path_segment.starts_with('-') } // check whether a path segment contains only valid (read: portable) characters -fn check_portable_chars(path_segment: &String) -> bool { +fn check_portable_chars(path_segment: &str) -> bool { let valid_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-".to_string(); for ch in path_segment.chars() { if !valid_str.contains(ch) { diff --git a/src/printf/memo.rs b/src/printf/memo.rs index fdb2531ee..226178e4b 100644 --- a/src/printf/memo.rs +++ b/src/printf/memo.rs @@ -25,7 +25,7 @@ fn warn_excess_args(first_arg: &str) { } impl Memo { - pub fn new(pf_string: &String, pf_args_it: &mut Peekable>) -> Memo { + pub fn new(pf_string: &str, pf_args_it: &mut Peekable>) -> Memo { let mut pm = Memo { tokens: Vec::new() }; let mut tmp_token: Option>; let mut it = put_back_n(pf_string.chars()); diff --git a/src/printf/tokenize/num_format/num_format.rs b/src/printf/tokenize/num_format/num_format.rs index 5470b396e..391548464 100644 --- a/src/printf/tokenize/num_format/num_format.rs +++ b/src/printf/tokenize/num_format/num_format.rs @@ -11,7 +11,7 @@ use super::formatters::cninetyninehexfloatf::CninetyNineHexFloatf; use super::formatters::scif::Scif; use super::formatters::decf::Decf; -pub fn warn_expected_numeric(pf_arg: &String) { +pub fn warn_expected_numeric(pf_arg: &str) { // important: keep println here not print cli::err_msg(&format!("{}: expected a numeric value", pf_arg)); }