1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints (char not string)

This commit is contained in:
Roy Ivy III 2019-12-26 15:20:19 -06:00
parent 11d68d3e51
commit ec5ca193ac
6 changed files with 10 additions and 10 deletions

View file

@ -62,10 +62,10 @@ static DEFAULT_COLORS: &str = "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do
lazy_static! { lazy_static! {
static ref LS_COLORS: String = std::env::var("LS_COLORS").unwrap_or_else(|_| DEFAULT_COLORS.to_string()); static ref LS_COLORS: String = std::env::var("LS_COLORS").unwrap_or_else(|_| DEFAULT_COLORS.to_string());
static ref COLOR_MAP: HashMap<&'static str, &'static str> = { static ref COLOR_MAP: HashMap<&'static str, &'static str> = {
let codes = LS_COLORS.split(":"); let codes = LS_COLORS.split(':');
let mut map = HashMap::new(); let mut map = HashMap::new();
for c in codes { for c in codes {
let p: Vec<_> = c.split("=").collect(); let p: Vec<_> = c.split('=').collect();
if p.len() == 2 { if p.len() == 2 {
map.insert(p[0], p[1]); map.insert(p[0], p[1]);
} }

View file

@ -78,7 +78,7 @@ impl fmt::Display for DisplayableSuffix {
} }
fn parse_suffix(s: String) -> Result<(f64, Option<Suffix>)> { fn parse_suffix(s: String) -> Result<(f64, Option<Suffix>)> {
let with_i = s.ends_with("i"); let with_i = s.ends_with('i');
let mut iter = s.chars(); let mut iter = s.chars();
if with_i { if with_i {
iter.next_back(); iter.next_back();

View file

@ -128,7 +128,7 @@ pub fn parse_format_flags(args: &Vec<String>) -> Result<Vec<ParsedFormatterItemI
if arg == "--format" { if arg == "--format" {
expect_type_string = true; expect_type_string = true;
} }
} else if arg.starts_with("-") { } else if arg.starts_with('-') {
let flags = arg.chars().skip(1); let flags = arg.chars().skip(1);
let mut format_spec = String::new(); let mut format_spec = String::new();
for c in flags { for c in flags {

View file

@ -55,7 +55,7 @@ pub fn parse_inputs(matches: &dyn CommandLineOpts) -> Result<CommandLineInputs,
match offset { match offset {
Ok(n) => { Ok(n) => {
// if there is just 1 input (stdin), an offset must start with '+' // if there is just 1 input (stdin), an offset must start with '+'
if input_strings.len() == 1 && input_strings[0].starts_with("+") { if input_strings.len() == 1 && input_strings[0].starts_with('+') {
return Ok(CommandLineInputs::FileAndOffset(("-".to_string(), n, None))); return Ok(CommandLineInputs::FileAndOffset(("-".to_string(), n, None)));
} }
if input_strings.len() == 2 { if input_strings.len() == 2 {
@ -137,7 +137,7 @@ pub fn parse_offset_operand(s: &str) -> Result<usize, &'static str> {
let mut radix = 8; let mut radix = 8;
let mut multiply = 1; let mut multiply = 1;
if s.starts_with("+") { if s.starts_with('+') {
start += 1; start += 1;
} }
@ -145,11 +145,11 @@ pub fn parse_offset_operand(s: &str) -> Result<usize, &'static str> {
start += 2; start += 2;
radix = 16; radix = 16;
} else { } else {
if s[start..len].ends_with("b") { if s[start..len].ends_with('b') {
len -= 1; len -= 1;
multiply = 512; multiply = 512;
} }
if s[start..len].ends_with(".") { if s[start..len].ends_with('.') {
len -= 1; len -= 1;
radix = 10; radix = 10;
} }

View file

@ -7,7 +7,7 @@ pub fn parse_number_of_bytes(s: &str) -> Result<usize, &'static str> {
if s.starts_with("0x") || s.starts_with("0X") { if s.starts_with("0x") || s.starts_with("0X") {
start = 2; start = 2;
radix = 16; radix = 16;
} else if s.starts_with("0") { } else if s.starts_with('0') {
radix = 8; radix = 8;
} }

View file

@ -22,7 +22,7 @@ struct SeqOptions {
} }
fn parse_float(mut s: &str) -> Result<f64, String> { fn parse_float(mut s: &str) -> Result<f64, String> {
if s.starts_with("+") { if s.starts_with('+') {
s = &s[1..]; s = &s[1..];
} }
match s.parse() { match s.parse() {