diff --git a/src/fs/dir.rs b/src/fs/dir.rs index 98dafa33e..0f76f648b 100644 --- a/src/fs/dir.rs +++ b/src/fs/dir.rs @@ -108,7 +108,7 @@ pub struct Files<'dir, 'ig> { total_size: bool, } -impl<'dir, 'ig> Files<'dir, 'ig> { +impl<'dir> Files<'dir, '_> { fn parent(&self) -> PathBuf { // We can’t use `Path#parent` here because all it does is remove the // last path component, which is no good for us if the path is @@ -180,7 +180,7 @@ enum DotsNext { Files, } -impl<'dir, 'ig> Iterator for Files<'dir, 'ig> { +impl<'dir> Iterator for Files<'dir, '_> { type Item = File<'dir>; fn next(&mut self) -> Option { diff --git a/src/fs/feature/xattr.rs b/src/fs/feature/xattr.rs index f05bfaf72..d064d67d1 100644 --- a/src/fs/feature/xattr.rs +++ b/src/fs/feature/xattr.rs @@ -672,7 +672,7 @@ struct BorrowedWriter<'a> { pub buffer: &'a mut Vec, } -impl<'a> io::Write for BorrowedWriter<'a> { +impl io::Write for BorrowedWriter<'_> { fn write(&mut self, buf: &[u8]) -> io::Result { self.buffer.write(buf) } diff --git a/src/fs/file.rs b/src/fs/file.rs index bd181de8b..09c60bdac 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -1007,7 +1007,7 @@ pub enum FileTarget<'dir> { // error — we just display the error message and move on. } -impl<'dir> FileTarget<'dir> { +impl FileTarget<'_> { /// Whether this link doesn’t lead to a file, for whatever reason. This /// gets used to determine how to highlight the link in grid views. pub fn is_broken(&self) -> bool { diff --git a/src/info/sources.rs b/src/info/sources.rs index 4e93a8db2..25f138295 100644 --- a/src/info/sources.rs +++ b/src/info/sources.rs @@ -8,7 +8,7 @@ use std::path::PathBuf; use crate::fs::File; -impl<'a> File<'a> { +impl File<'_> { /// For this file, return a vector of alternate file paths that, if any of /// them exist, mean that *this* file should be coloured as “compiled”. /// diff --git a/src/main.rs b/src/main.rs index a235180e7..36dac8112 100644 --- a/src/main.rs +++ b/src/main.rs @@ -248,7 +248,7 @@ fn git_repos(options: &Options, args: &[&OsStr]) -> bool { } } -impl<'args> Exa<'args> { +impl Exa<'_> { /// # Errors /// /// Will return `Err` if printing to stderr fails. diff --git a/src/options/parser.rs b/src/options/parser.rs index 8dbd7edd9..2e694a56d 100644 --- a/src/options/parser.rs +++ b/src/options/parser.rs @@ -399,7 +399,7 @@ pub struct MatchedFlags<'args> { strictness: Strictness, } -impl<'a> MatchedFlags<'a> { +impl MatchedFlags<'_> { /// Whether the given argument was specified. /// Returns `true` if it was, `false` if it wasn’t, and an error in /// strict mode if it was specified more than once. @@ -554,14 +554,14 @@ impl fmt::Display for ParseError { fn os_str_to_bytes(s: &OsStr) -> &[u8] { use std::os::unix::ffi::OsStrExt; - return s.as_bytes(); + s.as_bytes() } #[cfg(unix)] fn bytes_to_os_str(b: &[u8]) -> &OsStr { use std::os::unix::ffi::OsStrExt; - return OsStr::from_bytes(b); + OsStr::from_bytes(b) } #[cfg(windows)] diff --git a/src/output/details.rs b/src/output/details.rs index 343656f45..107991426 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -488,7 +488,7 @@ pub struct TableIter<'a> { tree_trunk: TreeTrunk, } -impl<'a> Iterator for TableIter<'a> { +impl Iterator for TableIter<'_> { type Item = TextCell; fn next(&mut self) -> Option { diff --git a/src/output/file_name.rs b/src/output/file_name.rs index ae232a3d9..f91bf55b5 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -165,7 +165,7 @@ pub struct FileName<'a, 'dir, C> { mount_style: MountStyle, } -impl<'a, 'dir, C> FileName<'a, 'dir, C> { +impl FileName<'_, '_, C> { /// Sets the flag on this file name to display link targets with an /// arrow followed by their path. pub fn with_link_paths(mut self) -> Self { @@ -187,7 +187,7 @@ impl<'a, 'dir, C> FileName<'a, 'dir, C> { } } -impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> { +impl FileName<'_, '_, C> { /// Paints the name of the file using the colours, resulting in a vector /// of coloured cells that can be printed to the terminal. /// diff --git a/src/output/grid.rs b/src/output/grid.rs index a52df4acc..500d42a95 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -37,7 +37,7 @@ pub struct Render<'a> { pub filter: &'a FileFilter, } -impl<'a> Render<'a> { +impl Render<'_> { pub fn render(mut self, w: &mut W) -> io::Result<()> { self.filter.sort_files(&mut self.files); diff --git a/src/output/render/permissions.rs b/src/output/render/permissions.rs index 71edd574e..23a815ccc 100644 --- a/src/output/render/permissions.rs +++ b/src/output/render/permissions.rs @@ -19,50 +19,46 @@ pub trait PermissionsPlusRender { impl PermissionsPlusRender for Option { #[cfg(unix)] fn render(&self, colours: &C) -> TextCell { - match self { - Some(p) => { - let mut chars = vec![p.file_type.render(colours)]; - let permissions = p.permissions; - chars.extend(Some(permissions).render(colours, p.file_type.is_regular_file())); - - if p.xattrs { - chars.push(colours.attribute().paint("@")); - } - - // As these are all ASCII characters, we can guarantee that they’re - // all going to be one character wide, and don’t need to compute the - // cell’s display width. - TextCell { - width: DisplayWidth::from(chars.len()), - contents: chars.into(), - } + if let Some(p) = self { + let mut chars = vec![p.file_type.render(colours)]; + let permissions = p.permissions; + chars.extend(Some(permissions).render(colours, p.file_type.is_regular_file())); + + if p.xattrs { + chars.push(colours.attribute().paint("@")); + } + + // As these are all ASCII characters, we can guarantee that they’re + // all going to be one character wide, and don’t need to compute the + // cell’s display width. + TextCell { + width: DisplayWidth::from(chars.len()), + contents: chars.into(), } - None => { - let chars: Vec<_> = iter::repeat(colours.dash().paint("-")).take(10).collect(); - TextCell { - width: DisplayWidth::from(chars.len()), - contents: chars.into(), - } + } else { + let chars: Vec<_> = iter::repeat(colours.dash().paint("-")).take(10).collect(); + TextCell { + width: DisplayWidth::from(chars.len()), + contents: chars.into(), } } } #[cfg(windows)] fn render(&self, colours: &C) -> TextCell { - match self { - Some(p) => { - let mut chars = vec![p.attributes.render_type(colours)]; - chars.extend(p.attributes.render(colours)); + if let Some(p) = self { + let mut chars = vec![p.attributes.render_type(colours)]; + chars.extend(p.attributes.render(colours)); - TextCell { - width: DisplayWidth::from(chars.len()), - contents: chars.into(), - } + TextCell { + width: DisplayWidth::from(chars.len()), + contents: chars.into(), } - None => TextCell { + } else { + TextCell { width: DisplayWidth::from(0), contents: vec![].into(), - }, + } } } } diff --git a/src/output/render/times.rs b/src/output/render/times.rs index a8463c95e..4e3bb640a 100644 --- a/src/output/render/times.rs +++ b/src/output/render/times.rs @@ -20,7 +20,7 @@ impl Render for Option { let datestamp = if let Ok(timezone_str) = iana_time_zone::get_timezone() { let timezone: Tz = timezone_str .parse() - .unwrap_or_else(|_| panic!("The timezone cannot be parsed: {}", timezone_str)); + .unwrap_or_else(|_| panic!("The timezone cannot be parsed: {timezone_str}")); if let Some(time) = self { let time_offset = timezone.offset_from_utc_datetime(&time).fix(); time_format.format(&DateTime::::from_naive_utc_and_offset( diff --git a/src/theme/lsc.rs b/src/theme/lsc.rs index 5fdd574ad..3fdf58cbf 100644 --- a/src/theme/lsc.rs +++ b/src/theme/lsc.rs @@ -97,7 +97,7 @@ pub struct Pair<'var> { pub value: &'var str, } -impl<'var> Pair<'var> { +impl Pair<'_> { pub fn to_style(&self) -> Style { let mut style = Style::default(); let mut iter = self.value.split(';').peekable();