1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #7703 from nyurik/lints

feat: minor linting
This commit is contained in:
Sylvestre Ledru 2025-04-08 17:16:42 -04:00 committed by GitHub
commit 6ea1f5247f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 11 additions and 19 deletions

View file

@ -47,10 +47,7 @@ impl SplitName {
.transpose()? .transpose()?
.unwrap_or(2); .unwrap_or(2);
let format_string = match format_opt { let format_string = format_opt.unwrap_or_else(|| format!("%0{n_digits}u"));
Some(f) => f,
None => format!("%0{n_digits}u"),
};
let format = match Format::<UnsignedInt, u64>::parse(format_string) { let format = match Format::<UnsignedInt, u64>::parse(format_string) {
Ok(format) => Ok(format), Ok(format) => Ok(format),

View file

@ -61,7 +61,7 @@ mod exact_searcher_tests {
let matcher = ExactMatcher::new("a".as_bytes()); let matcher = ExactMatcher::new("a".as_bytes());
let iter = Searcher::new(&matcher, "".as_bytes()); let iter = Searcher::new(&matcher, "".as_bytes());
let items: Vec<(usize, usize)> = iter.collect(); let items: Vec<(usize, usize)> = iter.collect();
assert_eq!(vec![] as Vec<(usize, usize)>, items); assert!(items.is_empty());
} }
fn test_multibyte(line: &[u8], expected: &[(usize, usize)]) { fn test_multibyte(line: &[u8], expected: &[(usize, usize)]) {
@ -140,7 +140,7 @@ mod whitespace_searcher_tests {
let matcher = WhitespaceMatcher {}; let matcher = WhitespaceMatcher {};
let iter = Searcher::new(&matcher, "".as_bytes()); let iter = Searcher::new(&matcher, "".as_bytes());
let items: Vec<(usize, usize)> = iter.collect(); let items: Vec<(usize, usize)> = iter.collect();
assert_eq!(vec![] as Vec<(usize, usize)>, items); assert!(items.is_empty());
} }
fn test_multispace(line: &[u8], expected: &[(usize, usize)]) { fn test_multispace(line: &[u8], expected: &[(usize, usize)]) {

View file

@ -442,7 +442,7 @@ fn parse_bytes_only(s: &str, i: usize) -> Result<u64, ParseError> {
/// 512. You can also use standard block size suffixes like `'k'` for /// 512. You can also use standard block size suffixes like `'k'` for
/// 1024. /// 1024.
/// ///
/// If the number would be too large, return [`std::u64::MAX`] instead. /// If the number would be too large, return [`u64::MAX`] instead.
/// ///
/// # Errors /// # Errors
/// ///

View file

@ -124,10 +124,7 @@ pub enum MainFunction {
impl Behavior { impl Behavior {
/// Determine the mode for chmod after copy. /// Determine the mode for chmod after copy.
pub fn mode(&self) -> u32 { pub fn mode(&self) -> u32 {
match self.specified_mode { self.specified_mode.unwrap_or(DEFAULT_MODE)
Some(x) => x,
None => DEFAULT_MODE,
}
} }
} }

View file

@ -104,11 +104,11 @@ impl<'a> StyleManager<'a> {
ret ret
} }
pub(crate) fn is_current_style(&mut self, new_style: &Style) -> bool { pub(crate) fn is_current_style(&self, new_style: &Style) -> bool {
matches!(&self.current_style, Some(style) if style == new_style) matches!(&self.current_style, Some(style) if style == new_style)
} }
pub(crate) fn is_reset(&mut self) -> bool { pub(crate) fn is_reset(&self) -> bool {
self.current_style.is_none() self.current_style.is_none()
} }

View file

@ -3,8 +3,6 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use half::f16; use half::f16;
use std::f32;
use std::f64;
use std::num::FpCategory; use std::num::FpCategory;
use crate::formatteriteminfo::{FormatWriter, FormatterItemInfo}; use crate::formatteriteminfo::{FormatWriter, FormatterItemInfo};

View file

@ -535,7 +535,7 @@ impl LineFormat {
let mut parts = checksum.splitn(2, |&b| b == b'='); let mut parts = checksum.splitn(2, |&b| b == b'=');
let main = parts.next().unwrap(); // Always exists since checksum isn't empty let main = parts.next().unwrap(); // Always exists since checksum isn't empty
let padding = parts.next().unwrap_or(&b""[..]); // Empty if no '=' let padding = parts.next().unwrap_or_default(); // Empty if no '='
main.iter() main.iter()
.all(|&b| b.is_ascii_alphanumeric() || b == b'+' || b == b'/') .all(|&b| b.is_ascii_alphanumeric() || b == b'+' || b == b'/')

View file

@ -1123,7 +1123,7 @@ mod test {
U: Formatter<T>, U: Formatter<T>,
{ {
let mut v = Vec::<u8>::new(); let mut v = Vec::<u8>::new();
format.fmt(&mut v, n as T).unwrap(); format.fmt(&mut v, n).unwrap();
String::from_utf8_lossy(&v).to_string() String::from_utf8_lossy(&v).to_string()
} }