diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 2777acd63..40c427aaf 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -40,7 +40,7 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber { return PreciseNumber { number: ebd, num_integral_digits: 0, - num_fractional_digits: if input.contains(".") || input.contains("p") { + num_fractional_digits: if input.contains('.') || input.contains('p') { None } else { Some(0) @@ -49,17 +49,17 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber { } // Split the exponent part, if any - let parts: Vec<&str> = input.split("e").collect(); + let parts: Vec<&str> = input.split('e').collect(); debug_assert!(parts.len() <= 2); // Count all the digits up to `.`, `-` sign is included. - let (mut int_digits, mut frac_digits) = match parts[0].find(".") { + let (mut int_digits, mut frac_digits) = match parts[0].find('.') { Some(i) => { // Cover special case .X and -.X where we behave as if there was a leading 0: // 0.X, -0.X. let int_digits = match i { 0 => 1, - 1 if parts[0].starts_with("-") => 2, + 1 if parts[0].starts_with('-') => 2, _ => i, }; @@ -75,7 +75,7 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber { // For positive exponents, effectively expand the number. Ignore negative exponents. // Also ignore overflowed exponents (unwrap_or(0)). if exp > 0 { - int_digits += exp.try_into().unwrap_or(0) + int_digits += exp.try_into().unwrap_or(0); }; frac_digits = if exp < frac_digits as i64 { // Subtract from i128 to avoid any overflow @@ -106,7 +106,7 @@ impl FromStr for PreciseNumber { ebd } ExtendedBigDecimal::Infinity | ExtendedBigDecimal::MinusInfinity => { - return Ok(PreciseNumber { + return Ok(Self { number: ebd, num_integral_digits: 0, num_fractional_digits: Some(0), diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 4c050c2c7..6e0910951 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -106,10 +106,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let options = SeqOptions { separator: matches .get_one::(OPT_SEPARATOR) - .map_or(OsString::from("\n"), |s| s.to_os_string()), + .cloned() + .unwrap_or_else(|| OsString::from("\n")), terminator: matches .get_one::(OPT_TERMINATOR) - .map_or(OsString::from("\n"), |s| s.to_os_string()), + .cloned() + .unwrap_or_else(|| OsString::from("\n")), equal_width: matches.get_flag(OPT_EQUAL_WIDTH), format: matches.get_one::(OPT_FORMAT).map(|s| s.as_str()), };