diff options
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/details.rs | 10 | ||||
-rw-r--r-- | src/output/file_name.rs | 6 | ||||
-rw-r--r-- | src/output/grid.rs | 4 | ||||
-rw-r--r-- | src/output/grid_details.rs | 4 | ||||
-rw-r--r-- | src/output/icons.rs | 9 | ||||
-rw-r--r-- | src/output/lines.rs | 2 | ||||
-rw-r--r-- | src/output/render/blocks.rs | 6 | ||||
-rw-r--r-- | src/output/render/filetype.rs | 4 | ||||
-rw-r--r-- | src/output/render/git.rs | 6 | ||||
-rw-r--r-- | src/output/render/groups.rs | 2 | ||||
-rw-r--r-- | src/output/render/inode.rs | 2 | ||||
-rw-r--r-- | src/output/render/size.rs | 6 | ||||
-rw-r--r-- | src/output/render/users.rs | 2 | ||||
-rw-r--r-- | src/output/table.rs | 26 | ||||
-rw-r--r-- | src/output/time.rs | 28 | ||||
-rw-r--r-- | src/output/tree.rs | 6 |
16 files changed, 62 insertions, 61 deletions
diff --git a/src/output/details.rs b/src/output/details.rs index 6b79177..4583d6b 100644 --- a/src/output/details.rs +++ b/src/output/details.rs @@ -162,7 +162,7 @@ impl<'a> Render<'a> { (None, _) => {/* Keep Git how it is */}, } - let mut table = Table::new(&table, git, &self.colours); + let mut table = Table::new(table, git, self.colours); if self.opts.header { let header = table.header_row(); @@ -248,7 +248,7 @@ impl<'a> Render<'a> { } } - let table_row = table.as_ref().map(|t| t.row_for_file(&file, !xattrs.is_empty())); + let table_row = table.as_ref().map(|t| t.row_for_file(file, !xattrs.is_empty())); if !self.opts.xattr { xattrs.clear(); @@ -266,7 +266,7 @@ impl<'a> Render<'a> { }; let icon = if self.opts.icons { - Some(painted_icon(&file, &self.style)) + Some(painted_icon(file, self.style)) } else { None }; let egg = Egg { table_row, xattrs, errors, dir, file, icon }; @@ -283,7 +283,7 @@ impl<'a> Render<'a> { let mut files = Vec::new(); let mut errors = egg.errors; - if let (Some(ref mut t), Some(ref row)) = (table.as_mut(), egg.table_row.as_ref()) { + if let (Some(ref mut t), Some(row)) = (table.as_mut(), egg.table_row.as_ref()) { t.add_widths(row); } @@ -291,7 +291,7 @@ impl<'a> Render<'a> { if let Some(icon) = egg.icon { name_cell.push(ANSIGenericString::from(icon), 2) } - name_cell.append(self.style.for_file(&egg.file, self.colours) + name_cell.append(self.style.for_file(egg.file, self.colours) .with_link_paths() .paint() .promote()); diff --git a/src/output/file_name.rs b/src/output/file_name.rs index 526fedd..e927990 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -133,8 +133,8 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> { } if let (LinkStyle::FullLinkPaths, Some(target)) = (self.link_style, self.target.as_ref()) { - match *target { - FileTarget::Ok(ref target) => { + match target { + FileTarget::Ok(target) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.normal_arrow().paint("->")); bits.push(Style::default().paint(" ")); @@ -159,7 +159,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> { } }, - FileTarget::Broken(ref broken_path) => { + FileTarget::Broken(broken_path) => { bits.push(Style::default().paint(" ")); bits.push(self.colours.broken_symlink().paint("->")); bits.push(Style::default().paint(" ")); diff --git a/src/output/grid.rs b/src/output/grid.rs index b1c671c..05c7fdc 100644 --- a/src/output/grid.rs +++ b/src/output/grid.rs @@ -41,7 +41,7 @@ impl<'a> Render<'a> { grid.reserve(self.files.len()); for file in &self.files { - let icon = if self.opts.icons { Some(painted_icon(&file, &self.style)) } else { None }; + let icon = if self.opts.icons { Some(painted_icon(file, self.style)) } else { None }; let filename = self.style.for_file(file, self.colours).paint(); let width = if self.opts.icons { DisplayWidth::from(2) + filename.width() @@ -64,7 +64,7 @@ impl<'a> Render<'a> { // displays full link paths. for file in &self.files { if self.opts.icons { - write!(w, "{}", painted_icon(&file, &self.style))?; + write!(w, "{}", painted_icon(file, self.style))?; } let name_cell = self.style.for_file(file, self.colours).paint(); writeln!(w, "{}", name_cell.strings())?; diff --git a/src/output/grid_details.rs b/src/output/grid_details.rs index 9ffedd1..bd995fb 100644 --- a/src/output/grid_details.rs +++ b/src/output/grid_details.rs @@ -112,7 +112,7 @@ impl<'a> Render<'a> { style: self.style, opts: self.details, recurse: None, - filter: &self.filter, + filter: self.filter, git_ignoring: self.git_ignoring, } } @@ -144,7 +144,7 @@ impl<'a> Render<'a> { .map(|file| { if self.details.icons { let mut icon_cell = TextCell::default(); - icon_cell.push(ANSIGenericString::from(painted_icon(&file, &self.style)), 2); + icon_cell.push(ANSIGenericString::from(painted_icon(file, self.style)), 2); let file_cell = self.style.for_file(file, self.colours).paint().promote(); icon_cell.append(file_cell); icon_cell diff --git a/src/output/icons.rs b/src/output/icons.rs index 7af0a9f..1e8ad5f 100644 --- a/src/output/icons.rs +++ b/src/output/icons.rs @@ -8,6 +8,7 @@ pub trait FileIcon { fn icon_file(&self, file: &File) -> Option<char>; } +#[derive(Copy, Clone)] pub enum Icons { Audio, Image, @@ -15,8 +16,8 @@ pub enum Icons { } impl Icons { - pub fn value(&self) -> char { - match *self { + pub fn value(self) -> char { + match self { Self::Audio => '\u{f001}', Self::Image => '\u{f1c5}', Self::Video => '\u{f03d}', @@ -25,9 +26,9 @@ impl Icons { } pub fn painted_icon(file: &File, style: &FileStyle) -> String { - let file_icon = icon(&file).to_string(); + let file_icon = icon(file).to_string(); let painted = style.exts - .colour_file(&file) + .colour_file(file) .map_or(file_icon.to_string(), |c| { // Remove underline from icon if c.is_underline { diff --git a/src/output/lines.rs b/src/output/lines.rs index 22407c2..c92e9e4 100644 --- a/src/output/lines.rs +++ b/src/output/lines.rs @@ -28,7 +28,7 @@ impl<'a> Render<'a> { if self.opts.icons { // Create a TextCell for the icon then append the text to it let mut cell = TextCell::default(); - let icon = painted_icon(&file, self.style); + let icon = painted_icon(file, self.style); cell.push(ANSIGenericString::from(icon), 2); cell.append(name_cell.promote()); writeln!(w, "{}", ANSIStrings(&cell))?; diff --git a/src/output/render/blocks.rs b/src/output/render/blocks.rs index 97e2e8d..e5b8f88 100644 --- a/src/output/render/blocks.rs +++ b/src/output/render/blocks.rs @@ -6,9 +6,9 @@ use crate::fs::fields as f; impl f::Blocks { pub fn render<C: Colours>(&self, colours: &C) -> TextCell { - match *self { - Self::Some(ref blk) => TextCell::paint(colours.block_count(), blk.to_string()), - Self::None => TextCell::blank(colours.no_blocks()), + match self { + Self::Some(blk) => TextCell::paint(colours.block_count(), blk.to_string()), + Self::None => TextCell::blank(colours.no_blocks()), } } } diff --git a/src/output/render/filetype.rs b/src/output/render/filetype.rs index 5ba60fa..417bccb 100644 --- a/src/output/render/filetype.rs +++ b/src/output/render/filetype.rs @@ -4,8 +4,8 @@ use crate::fs::fields as f; impl f::Type { - pub fn render<C: Colours>(&self, colours: &C) -> ANSIString<'static> { - match *self { + pub fn render<C: Colours>(self, colours: &C) -> ANSIString<'static> { + match self { Self::File => colours.normal().paint("."), Self::Directory => colours.directory().paint("d"), Self::Pipe => colours.pipe().paint("|"), diff --git a/src/output/render/git.rs b/src/output/render/git.rs index ddeec01..b4b3d74 100644 --- a/src/output/render/git.rs +++ b/src/output/render/git.rs @@ -5,7 +5,7 @@ use crate::fs::fields as f; impl f::Git { - pub fn render(&self, colours: &dyn Colours) -> TextCell { + pub fn render(self, colours: &dyn Colours) -> TextCell { TextCell { width: DisplayWidth::from(2), contents: vec![ @@ -18,8 +18,8 @@ impl f::Git { impl f::GitStatus { - fn render(&self, colours: &dyn Colours) -> ANSIString<'static> { - match *self { + fn render(self, colours: &dyn Colours) -> ANSIString<'static> { + match self { Self::NotModified => colours.not_modified().paint("-"), Self::New => colours.new().paint("N"), Self::Modified => colours.modified().paint("M"), diff --git a/src/output/render/groups.rs b/src/output/render/groups.rs index 4f78c0d..f46d257 100644 --- a/src/output/render/groups.rs +++ b/src/output/render/groups.rs @@ -6,7 +6,7 @@ use crate::output::cell::TextCell; impl f::Group { - pub fn render<C: Colours, U: Users+Groups>(&self, colours: &C, users: &U) -> TextCell { + pub fn render<C: Colours, U: Users+Groups>(self, colours: &C, users: &U) -> TextCell { use users::os::unix::GroupExt; let mut style = colours.not_yours(); diff --git a/src/output/render/inode.rs b/src/output/render/inode.rs index 4bd675e..0188de7 100644 --- a/src/output/render/inode.rs +++ b/src/output/render/inode.rs @@ -5,7 +5,7 @@ use crate::fs::fields as f; impl f::Inode { - pub fn render(&self, style: Style) -> TextCell { + pub fn render(self, style: Style) -> TextCell { TextCell::paint(style, self.0.to_string()) } } diff --git a/src/output/render/size.rs b/src/output/render/size.rs index 969a489..498f647 100644 --- a/src/output/render/size.rs +++ b/src/output/render/size.rs @@ -8,10 +8,10 @@ use crate::output::table::SizeFormat; impl f::Size { - pub fn render<C: Colours>(&self, colours: &C, size_format: SizeFormat, numerics: &NumericLocale) -> TextCell { + pub fn render<C: Colours>(self, colours: &C, size_format: SizeFormat, numerics: &NumericLocale) -> TextCell { use number_prefix::NumberPrefix; - let size = match *self { + let size = match self { Self::Some(s) => s, Self::None => return TextCell::blank(colours.no_size()), Self::DeviceIDs(ref ids) => return ids.render(colours), @@ -57,7 +57,7 @@ impl f::Size { impl f::DeviceIDs { - fn render<C: Colours>(&self, colours: &C) -> TextCell { + fn render<C: Colours>(self, colours: &C) -> TextCell { let major = self.major.to_string(); let minor = self.minor.to_string(); diff --git a/src/output/render/users.rs b/src/output/render/users.rs index 1682fb1..cacdfb8 100644 --- a/src/output/render/users.rs +++ b/src/output/render/users.rs @@ -7,7 +7,7 @@ use crate::output::cell::TextCell; impl f::User { - pub fn render<C: Colours, U: Users>(&self, colours: &C, users: &U) -> TextCell { + pub fn render<C: Colours, U: Users>(self, colours: &C, users: &U) -> TextCell { let user_name = match users.get_user_by_uid(self.0) { Some(user) => user.name().to_string_lossy().into(), None => self.0.to_string(), diff --git a/src/output/table.rs b/src/output/table.rs index 8caad45..f44fc84 100644 --- a/src/output/table.rs +++ b/src/output/table.rs @@ -36,7 +36,7 @@ impl fmt::Debug for Options { } /// Extra columns to display in the table. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Debug, Copy, Clone)] pub struct Columns { /// At least one of these timestamps will be shown. @@ -118,7 +118,7 @@ impl Columns { /// A table contains these. -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] pub enum Column { Permissions, FileSize, @@ -142,8 +142,8 @@ pub enum Alignment { impl Column { /// Get the alignment this column should use. - pub fn alignment(&self) -> Alignment { - match *self { + pub fn alignment(self) -> Alignment { + match self { Self::FileSize | Self::HardLinks | Self::Inode | @@ -155,8 +155,8 @@ impl Column { /// Get the text that should be printed at the top, when the user elects /// to have a header row printed. - pub fn header(&self) -> &'static str { - match *self { + pub fn header(self) -> &'static str { + match self { Self::Permissions => "Permissions", Self::FileSize => "Size", Self::Timestamp(t) => t.header(), @@ -342,7 +342,7 @@ impl<'a, 'f> Table<'a> { pub fn row_for_file(&self, file: &File, xattrs: bool) -> Row { let cells = self.columns.iter() - .map(|c| self.display(file, c, xattrs)) + .map(|c| self.display(file, *c, xattrs)) .collect(); Row { cells } @@ -366,10 +366,10 @@ impl<'a, 'f> Table<'a> { } } - fn display(&self, file: &File, column: &Column, xattrs: bool) -> TextCell { + fn display(&self, file: &File, column: Column, xattrs: bool) -> TextCell { use crate::output::table::TimeType::*; - match *column { + match column { Column::Permissions => self.permissions_plus(file, xattrs).render(self.colours), Column::FileSize => file.size().render(self.colours, self.size_format, &self.env.numeric), Column::HardLinks => file.links().render(self.colours, &self.env.numeric), @@ -380,10 +380,10 @@ impl<'a, 'f> Table<'a> { Column::GitStatus => self.git_status(file).render(self.colours), Column::Octal => self.octal_permissions(file).render(self.colours.octal), - Column::Timestamp(Modified) => file.modified_time().render(self.colours.date, &self.env.tz, &self.time_format), - Column::Timestamp(Changed) => file.changed_time() .render(self.colours.date, &self.env.tz, &self.time_format), - Column::Timestamp(Created) => file.created_time() .render(self.colours.date, &self.env.tz, &self.time_format), - Column::Timestamp(Accessed) => file.accessed_time().render(self.colours.date, &self.env.tz, &self.time_format), + Column::Timestamp(Modified) => file.modified_time().render(self.colours.date, &self.env.tz, self.time_format), + Column::Timestamp(Changed) => file.changed_time() .render(self.colours.date, &self.env.tz, self.time_format), + Column::Timestamp(Created) => file.created_time() .render(self.colours.date, &self.env.tz, self.time_format), + Column::Timestamp(Accessed) => file.accessed_time().render(self.colours.date, &self.env.tz, self.time_format), } } diff --git a/src/output/time.rs b/src/output/time.rs index 551b548..521512c 100644 --- a/src/output/time.rs +++ b/src/output/time.rs @@ -51,20 +51,20 @@ pub enum TimeFormat { impl TimeFormat { pub fn format_local(&self, time: SystemTime) -> String { - match *self { - Self::DefaultFormat(ref fmt) => fmt.format_local(time), - Self::ISOFormat(ref iso) => iso.format_local(time), - Self::LongISO => long_local(time), - Self::FullISO => full_local(time), + match self { + Self::DefaultFormat(fmt) => fmt.format_local(time), + Self::ISOFormat(iso) => iso.format_local(time), + Self::LongISO => long_local(time), + Self::FullISO => full_local(time), } } pub fn format_zoned(&self, time: SystemTime, zone: &TimeZone) -> String { - match *self { - Self::DefaultFormat(ref fmt) => fmt.format_zoned(time, zone), - Self::ISOFormat(ref iso) => iso.format_zoned(time, zone), - Self::LongISO => long_zoned(time, zone), - Self::FullISO => full_zoned(time, zone), + match self { + Self::DefaultFormat(fmt) => fmt.format_zoned(time, zone), + Self::ISOFormat(iso) => iso.format_zoned(time, zone), + Self::LongISO => long_zoned(time, zone), + Self::FullISO => full_zoned(time, zone), } } } @@ -241,7 +241,7 @@ fn full_zoned(time: SystemTime, zone: &TimeZone) -> String { -#[derive(Debug, Clone)] +#[derive(Debug, Copy, Clone)] pub struct ISOFormat { /// The year of the current time. This gets used to determine which date @@ -257,12 +257,12 @@ impl ISOFormat { } impl ISOFormat { - fn is_recent(&self, date: LocalDateTime) -> bool { + fn is_recent(self, date: LocalDateTime) -> bool { date.year() == self.current_year } #[allow(trivial_numeric_casts)] - fn format_local(&self, time: SystemTime) -> String { + fn format_local(self, time: SystemTime) -> String { let date = LocalDateTime::at(systemtime_epoch(time)); if self.is_recent(date) { @@ -277,7 +277,7 @@ impl ISOFormat { } #[allow(trivial_numeric_casts)] - fn format_zoned(&self, time: SystemTime, zone: &TimeZone) -> String { + fn format_zoned(self, time: SystemTime, zone: &TimeZone) -> String { let date = zone.to_zoned(LocalDateTime::at(systemtime_epoch(time))); if self.is_recent(date) { diff --git a/src/output/tree.rs b/src/output/tree.rs index 5a27fcb..ac1cbd1 100644 --- a/src/output/tree.rs +++ b/src/output/tree.rs @@ -39,7 +39,7 @@ //! each directory) -#[derive(PartialEq, Debug, Clone)] +#[derive(PartialEq, Debug, Copy, Clone)] pub enum TreePart { /// Rightmost column, *not* the last in the directory. @@ -59,8 +59,8 @@ impl TreePart { /// Turn this tree part into ASCII-licious box drawing characters! /// (Warning: not actually ASCII) - pub fn ascii_art(&self) -> &'static str { - match *self { + pub fn ascii_art(self) -> &'static str { + match self { Self::Edge => "├──", Self::Line => "│ ", Self::Corner => "└──", |