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:
parent
11d68d3e51
commit
ec5ca193ac
6 changed files with 10 additions and 10 deletions
|
@ -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! {
|
||||
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> = {
|
||||
let codes = LS_COLORS.split(":");
|
||||
let codes = LS_COLORS.split(':');
|
||||
let mut map = HashMap::new();
|
||||
for c in codes {
|
||||
let p: Vec<_> = c.split("=").collect();
|
||||
let p: Vec<_> = c.split('=').collect();
|
||||
if p.len() == 2 {
|
||||
map.insert(p[0], p[1]);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl fmt::Display for DisplayableSuffix {
|
|||
}
|
||||
|
||||
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();
|
||||
if with_i {
|
||||
iter.next_back();
|
||||
|
|
|
@ -128,7 +128,7 @@ pub fn parse_format_flags(args: &Vec<String>) -> Result<Vec<ParsedFormatterItemI
|
|||
if arg == "--format" {
|
||||
expect_type_string = true;
|
||||
}
|
||||
} else if arg.starts_with("-") {
|
||||
} else if arg.starts_with('-') {
|
||||
let flags = arg.chars().skip(1);
|
||||
let mut format_spec = String::new();
|
||||
for c in flags {
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn parse_inputs(matches: &dyn CommandLineOpts) -> Result<CommandLineInputs,
|
|||
match offset {
|
||||
Ok(n) => {
|
||||
// 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)));
|
||||
}
|
||||
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 multiply = 1;
|
||||
|
||||
if s.starts_with("+") {
|
||||
if s.starts_with('+') {
|
||||
start += 1;
|
||||
}
|
||||
|
||||
|
@ -145,11 +145,11 @@ pub fn parse_offset_operand(s: &str) -> Result<usize, &'static str> {
|
|||
start += 2;
|
||||
radix = 16;
|
||||
} else {
|
||||
if s[start..len].ends_with("b") {
|
||||
if s[start..len].ends_with('b') {
|
||||
len -= 1;
|
||||
multiply = 512;
|
||||
}
|
||||
if s[start..len].ends_with(".") {
|
||||
if s[start..len].ends_with('.') {
|
||||
len -= 1;
|
||||
radix = 10;
|
||||
}
|
||||
|
|
|
@ -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") {
|
||||
start = 2;
|
||||
radix = 16;
|
||||
} else if s.starts_with("0") {
|
||||
} else if s.starts_with('0') {
|
||||
radix = 8;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ struct SeqOptions {
|
|||
}
|
||||
|
||||
fn parse_float(mut s: &str) -> Result<f64, String> {
|
||||
if s.starts_with("+") {
|
||||
if s.starts_with('+') {
|
||||
s = &s[1..];
|
||||
}
|
||||
match s.parse() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue