Skip to content

Commit 6ea1f52

Browse files
authored
Merge pull request #7703 from nyurik/lints
feat: minor linting
2 parents 1abe65c + 249ef53 commit 6ea1f52

File tree

9 files changed

+11
-19
lines changed

9 files changed

+11
-19
lines changed

src/uu/csplit/src/split_name.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ impl SplitName {
4747
.transpose()?
4848
.unwrap_or(2);
4949

50-
let format_string = match format_opt {
51-
Some(f) => f,
52-
None => format!("%0{n_digits}u"),
53-
};
50+
let format_string = format_opt.unwrap_or_else(|| format!("%0{n_digits}u"));
5451

5552
let format = match Format::<UnsignedInt, u64>::parse(format_string) {
5653
Ok(format) => Ok(format),

src/uu/cut/src/searcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mod exact_searcher_tests {
6161
let matcher = ExactMatcher::new("a".as_bytes());
6262
let iter = Searcher::new(&matcher, "".as_bytes());
6363
let items: Vec<(usize, usize)> = iter.collect();
64-
assert_eq!(vec![] as Vec<(usize, usize)>, items);
64+
assert!(items.is_empty());
6565
}
6666

6767
fn test_multibyte(line: &[u8], expected: &[(usize, usize)]) {
@@ -140,7 +140,7 @@ mod whitespace_searcher_tests {
140140
let matcher = WhitespaceMatcher {};
141141
let iter = Searcher::new(&matcher, "".as_bytes());
142142
let items: Vec<(usize, usize)> = iter.collect();
143-
assert_eq!(vec![] as Vec<(usize, usize)>, items);
143+
assert!(items.is_empty());
144144
}
145145

146146
fn test_multispace(line: &[u8], expected: &[(usize, usize)]) {

src/uu/dd/src/parseargs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ fn parse_bytes_only(s: &str, i: usize) -> Result<u64, ParseError> {
442442
/// 512. You can also use standard block size suffixes like `'k'` for
443443
/// 1024.
444444
///
445-
/// If the number would be too large, return [`std::u64::MAX`] instead.
445+
/// If the number would be too large, return [`u64::MAX`] instead.
446446
///
447447
/// # Errors
448448
///

src/uu/install/src/install.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ pub enum MainFunction {
124124
impl Behavior {
125125
/// Determine the mode for chmod after copy.
126126
pub fn mode(&self) -> u32 {
127-
match self.specified_mode {
128-
Some(x) => x,
129-
None => DEFAULT_MODE,
130-
}
127+
self.specified_mode.unwrap_or(DEFAULT_MODE)
131128
}
132129
}
133130

src/uu/ln/src/ln.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ enum LnError {
5959
#[error("missing destination file operand after {}", _0.quote())]
6060
MissingDestination(PathBuf),
6161

62-
#[error("extra operand {}\nTry '{} --help' for more information.",
62+
#[error("extra operand {}\nTry '{} --help' for more information.",
6363
format!("{_0:?}").trim_matches('"'), _1)]
6464
ExtraOperand(OsString, String),
6565
}

src/uu/ls/src/colors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ impl<'a> StyleManager<'a> {
104104
ret
105105
}
106106

107-
pub(crate) fn is_current_style(&mut self, new_style: &Style) -> bool {
108-
matches!(&self.current_style,Some(style) if style == new_style )
107+
pub(crate) fn is_current_style(&self, new_style: &Style) -> bool {
108+
matches!(&self.current_style, Some(style) if style == new_style)
109109
}
110110

111-
pub(crate) fn is_reset(&mut self) -> bool {
111+
pub(crate) fn is_reset(&self) -> bool {
112112
self.current_style.is_none()
113113
}
114114

src/uu/od/src/prn_float.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
use half::f16;
6-
use std::f32;
7-
use std::f64;
86
use std::num::FpCategory;
97

108
use crate::formatteriteminfo::{FormatWriter, FormatterItemInfo};

src/uucore/src/lib/features/checksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl LineFormat {
535535

536536
let mut parts = checksum.splitn(2, |&b| b == b'=');
537537
let main = parts.next().unwrap(); // Always exists since checksum isn't empty
538-
let padding = parts.next().unwrap_or(&b""[..]); // Empty if no '='
538+
let padding = parts.next().unwrap_or_default(); // Empty if no '='
539539

540540
main.iter()
541541
.all(|&b| b.is_ascii_alphanumeric() || b == b'+' || b == b'/')

src/uucore/src/lib/features/format/num_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ mod test {
11231123
U: Formatter<T>,
11241124
{
11251125
let mut v = Vec::<u8>::new();
1126-
format.fmt(&mut v, n as T).unwrap();
1126+
format.fmt(&mut v, n).unwrap();
11271127
String::from_utf8_lossy(&v).to_string()
11281128
}
11291129

0 commit comments

Comments
 (0)