Skip to content

Commit 19284de

Browse files
committed
seq: fix warnings from workspace lints
1 parent 5b5eed4 commit 19284de

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/uu/seq/src/numberparse.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
4040
return PreciseNumber {
4141
number: ebd,
4242
num_integral_digits: 0,
43-
num_fractional_digits: if input.contains(".") || input.contains("p") {
43+
num_fractional_digits: if input.contains('.') || input.contains('p') {
4444
None
4545
} else {
4646
Some(0)
@@ -49,17 +49,17 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
4949
}
5050

5151
// Split the exponent part, if any
52-
let parts: Vec<&str> = input.split("e").collect();
52+
let parts: Vec<&str> = input.split('e').collect();
5353
debug_assert!(parts.len() <= 2);
5454

5555
// Count all the digits up to `.`, `-` sign is included.
56-
let (mut int_digits, mut frac_digits) = match parts[0].find(".") {
56+
let (mut int_digits, mut frac_digits) = match parts[0].find('.') {
5757
Some(i) => {
5858
// Cover special case .X and -.X where we behave as if there was a leading 0:
5959
// 0.X, -0.X.
6060
let int_digits = match i {
6161
0 => 1,
62-
1 if parts[0].starts_with("-") => 2,
62+
1 if parts[0].starts_with('-') => 2,
6363
_ => i,
6464
};
6565

@@ -75,7 +75,7 @@ fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
7575
// For positive exponents, effectively expand the number. Ignore negative exponents.
7676
// Also ignore overflowed exponents (unwrap_or(0)).
7777
if exp > 0 {
78-
int_digits += exp.try_into().unwrap_or(0)
78+
int_digits += exp.try_into().unwrap_or(0);
7979
};
8080
frac_digits = if exp < frac_digits as i64 {
8181
// Subtract from i128 to avoid any overflow
@@ -106,7 +106,7 @@ impl FromStr for PreciseNumber {
106106
ebd
107107
}
108108
ExtendedBigDecimal::Infinity | ExtendedBigDecimal::MinusInfinity => {
109-
return Ok(PreciseNumber {
109+
return Ok(Self {
110110
number: ebd,
111111
num_integral_digits: 0,
112112
num_fractional_digits: Some(0),

src/uu/seq/src/seq.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
106106
let options = SeqOptions {
107107
separator: matches
108108
.get_one::<OsString>(OPT_SEPARATOR)
109-
.map_or(OsString::from("\n"), |s| s.to_os_string()),
109+
.cloned()
110+
.unwrap_or_else(|| OsString::from("\n")),
110111
terminator: matches
111112
.get_one::<OsString>(OPT_TERMINATOR)
112-
.map_or(OsString::from("\n"), |s| s.to_os_string()),
113+
.cloned()
114+
.unwrap_or_else(|| OsString::from("\n")),
113115
equal_width: matches.get_flag(OPT_EQUAL_WIDTH),
114116
format: matches.get_one::<String>(OPT_FORMAT).map(|s| s.as_str()),
115117
};

0 commit comments

Comments
 (0)