Merge pull request #1125 from Tyrubias/upgrade-and-cleanup

Upgrade both Rust version and edition (and fix some lints)
This commit is contained in:
Mélanie Chauvel 2023-03-01 15:17:36 +01:00 committed by GitHub
commit c697d06670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 115 additions and 118 deletions

View File

@ -28,7 +28,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
rust: [1.56.1, stable, beta, nightly]
rust: [1.63.0, stable, beta, nightly]
steps:
- name: Checkout repository

View File

@ -3,8 +3,8 @@ name = "exa"
description = "A modern replacement for ls"
authors = ["Benjamin Sago <ogham@bsago.me>"]
categories = ["command-line-utilities"]
edition = "2018"
rust-version = "1.56.1"
edition = "2021"
rust-version = "1.63.0"
exclude = ["/devtools/*", "/Justfile", "/Vagrantfile", "/screenshots.png"]
readme = "README.md"
homepage = "https://the.exa.website/"

View File

@ -196,8 +196,8 @@ To build without Git support, run `cargo install --no-default-features exa` is a
<a id="development">
<h1>Development
<a href="https://blog.rust-lang.org/2021/11/01/Rust-1.56.1.html">
<img src="https://img.shields.io/badge/rustc-1.56.1+-lightgray.svg" alt="Rust 1.56.1+" />
<a href="https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html">
<img src="https://img.shields.io/badge/rustc-1.63.0+-lightgray.svg" alt="Rust 1.63.0+" />
</a>
<a href="https://github.com/ogham/exa/blob/master/LICENCE">

View File

@ -41,7 +41,7 @@ fn main() -> io::Result<()> {
let path = &out.join("version_string.txt");
// Bland version text
let mut f = File::create(path).expect(&path.to_string_lossy());
let mut f = File::create(path).unwrap_or_else(|_| { panic!("{}", path.to_string_lossy().to_string()) });
writeln!(f, "{}", strip_codes(&ver))?;
Ok(())

View File

@ -1,2 +1,2 @@
[toolchain]
channel = "1.56.1"
channel = "1.63.0"

View File

@ -176,7 +176,7 @@ impl<'dir, 'ig> Iterator for Files<'dir, 'ig> {
/// Usually files in Unix use a leading dot to be hidden or visible, but two
/// entries in particular are “extra-hidden”: `.` and `..`, which only become
/// visible after an extra `-a` option.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum DotFilter {
/// Shows files, dotfiles, and `.` and `..`.

View File

@ -19,7 +19,7 @@
/// into them and print out their contents. The recurse mode does this by
/// having extra output blocks at the end, while the tree mode will show
/// directories inline, with their contents immediately underneath.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum DirAction {
/// This directory should be listed along with the regular files, instead
@ -58,7 +58,7 @@ impl DirAction {
/// The options that determine how to recurse into a directory.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct RecurseOptions {
/// Whether recursion should be done as a tree or as multiple individual

View File

@ -167,7 +167,7 @@ mod lister {
unsafe {
listxattr(
c_path.as_ptr(),
buf.as_mut_ptr() as *mut c_char,
buf.as_mut_ptr().cast::<c_char>(),
bufsize as size_t,
self.c_flags,
)
@ -178,7 +178,7 @@ mod lister {
unsafe {
getxattr(
c_path.as_ptr(),
buf.as_ptr() as *const c_char,
buf.as_ptr().cast::<c_char>(),
ptr::null_mut(),
0,
0,

View File

@ -210,7 +210,7 @@ pub struct Time {
/// A files status in a Git repository. Whether a file is in a repository or
/// not is handled by the Git module, rather than having a “null” variant in
/// this enum.
#[derive(PartialEq, Copy, Clone)]
#[derive(PartialEq, Eq, Copy, Clone)]
pub enum GitStatus {
/// This file hasnt changed since the last commit.

View File

@ -221,13 +221,13 @@ impl<'dir> File<'dir> {
path.to_path_buf()
}
else if let Some(dir) = self.parent_dir {
dir.join(&*path)
dir.join(path)
}
else if let Some(parent) = self.path.parent() {
parent.join(&*path)
parent.join(path)
}
else {
self.path.join(&*path)
self.path.join(path)
}
}
@ -375,7 +375,7 @@ impl<'dir> File<'dir> {
nanosec -= 1_000_000_000;
}
let duration = Duration::new(sec.abs() as u64, nanosec.abs() as u32);
let duration = Duration::new(sec.unsigned_abs(), nanosec.unsigned_abs() as u32);
Some(UNIX_EPOCH - duration)
}
else {

View File

@ -23,7 +23,7 @@ use crate::fs::File;
/// The filter also governs sorting the list. After being filtered, pairs of
/// files are compared and sorted based on the result, with the sort field
/// performing the comparison.
#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct FileFilter {
/// Whether directories should be listed first, and other types of file
@ -89,7 +89,7 @@ impl FileFilter {
}
/// Sort the files in the given vector based on the sort field option.
pub fn sort_files<'a, F>(&self, files: &mut Vec<F>)
pub fn sort_files<'a, F>(&self, files: &mut [F])
where F: AsRef<File<'a>>
{
files.sort_by(|a, b| {
@ -113,7 +113,7 @@ impl FileFilter {
/// User-supplied field to sort by.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SortField {
/// Dont apply any sorting. This is usually used as an optimisation in
@ -194,7 +194,7 @@ pub enum SortField {
/// lowercase letters because it takes the difference between the two cases
/// into account? I gave up and just named these two variants after the
/// effects they have.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SortCase {
/// Sort files case-sensitively with uppercase first, with A coming
@ -271,7 +271,7 @@ impl SortField {
/// The **ignore patterns** are a list of globs that are tested against
/// each filename, and if any of them match, that file isnt displayed.
/// This lets a user hide, say, text files by ignoring `*.txt`.
#[derive(PartialEq, Default, Debug, Clone)]
#[derive(PartialEq, Eq, Default, Debug, Clone)]
pub struct IgnorePatterns {
patterns: Vec<glob::Pattern>,
}
@ -327,7 +327,7 @@ impl IgnorePatterns {
/// Whether to ignore or display files that Git would ignore.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum GitIgnore {
/// Ignore files that Git would ignore.
@ -346,31 +346,31 @@ mod test_ignores {
#[test]
fn empty_matches_nothing() {
let pats = IgnorePatterns::empty();
assert_eq!(false, pats.is_ignored("nothing"));
assert_eq!(false, pats.is_ignored("test.mp3"));
assert!(!pats.is_ignored("nothing"));
assert!(!pats.is_ignored("test.mp3"));
}
#[test]
fn ignores_a_glob() {
let (pats, fails) = IgnorePatterns::parse_from_iter(vec![ "*.mp3" ]);
assert!(fails.is_empty());
assert_eq!(false, pats.is_ignored("nothing"));
assert_eq!(true, pats.is_ignored("test.mp3"));
assert!(!pats.is_ignored("nothing"));
assert!(pats.is_ignored("test.mp3"));
}
#[test]
fn ignores_an_exact_filename() {
let (pats, fails) = IgnorePatterns::parse_from_iter(vec![ "nothing" ]);
assert!(fails.is_empty());
assert_eq!(true, pats.is_ignored("nothing"));
assert_eq!(false, pats.is_ignored("test.mp3"));
assert!(pats.is_ignored("nothing"));
assert!(!pats.is_ignored("test.mp3"));
}
#[test]
fn ignores_both() {
let (pats, fails) = IgnorePatterns::parse_from_iter(vec![ "nothing", "*.mp3" ]);
assert!(fails.is_empty());
assert_eq!(true, pats.is_ignored("nothing"));
assert_eq!(true, pats.is_ignored("test.mp3"));
assert!(pats.is_ignored("nothing"));
assert!(pats.is_ignored("test.mp3"));
}
}

View File

@ -11,7 +11,7 @@ use crate::output::icons::FileIcon;
use crate::theme::FileColours;
#[derive(Debug, Default, PartialEq)]
#[derive(Debug, Default, PartialEq, Eq)]
pub struct FileExtensions;
impl FileExtensions {

View File

@ -62,7 +62,7 @@ fn main() {
}
let args: Vec<_> = env::args_os().skip(1).collect();
match Options::parse(args.iter().map(|e| e.as_ref()), &LiveVars) {
match Options::parse(args.iter().map(std::convert::AsRef::as_ref), &LiveVars) {
OptionsResult::Ok(options, mut input_paths) => {
// List the current directory by default.

View File

@ -7,7 +7,7 @@ use crate::options::parser::{Arg, Flag, ParseError};
/// Something wrong with the combination of options the user has picked.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum OptionsError {
/// There was an error (from `getopts`) parsing the arguments.
@ -44,7 +44,7 @@ pub enum OptionsError {
}
/// The source of a string that failed to be parsed as a number.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum NumberSource {
/// It came... from a command-line argument!
@ -119,7 +119,7 @@ impl OptionsError {
/// A list of legal choices for an argument-taking option.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Choices(pub &'static [&'static str]);
impl fmt::Display for Choices {

View File

@ -295,7 +295,6 @@ mod test {
mod ignore_patterns {
use super::*;
use std::iter::FromIterator;
use glob;
fn pat(string: &'static str) -> glob::Pattern {
glob::Pattern::new(string).unwrap()

View File

@ -69,7 +69,7 @@ static EXTENDED_HELP: &str = " -@, --extended list each file's extended
/// All the information needed to display the help text, which depends
/// on which features are enabled and whether the user only wants to
/// see one sections help.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct HelpString;
impl HelpString {

View File

@ -216,7 +216,7 @@ pub mod test {
use crate::options::parser::{Arg, MatchedFlags};
use std::ffi::OsStr;
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum Strictnesses {
Last,
Complain,
@ -228,14 +228,14 @@ pub mod test {
/// both, then both should resolve to the same result.
///
/// It returns a vector with one or two elements in.
/// These elements can then be tested with assert_eq or what have you.
/// These elements can then be tested with `assert_eq` or what have you.
pub fn parse_for_test<T, F>(inputs: &[&str], args: &'static [&'static Arg], strictnesses: Strictnesses, get: F) -> Vec<T>
where F: Fn(&MatchedFlags<'_>) -> T
{
use self::Strictnesses::*;
use crate::options::parser::{Args, Strictness};
let bits = inputs.into_iter().map(OsStr::new).collect::<Vec<_>>();
let bits = inputs.iter().map(OsStr::new).collect::<Vec<_>>();
let mut result = Vec::new();
if strictnesses == Last || strictnesses == Both {

View File

@ -52,7 +52,7 @@ pub type Values = &'static [&'static str];
/// A **flag** is either of the two argument types, because they have to
/// be in the same array together.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Flag {
Short(ShortArg),
Long(LongArg),
@ -77,7 +77,7 @@ impl fmt::Display for Flag {
}
/// Whether redundant arguments should be considered a problem.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Strictness {
/// Throw an error when an argument doesnt do anything, either because
@ -91,7 +91,7 @@ pub enum Strictness {
/// Whether a flag takes a value. This is applicable to both long and short
/// arguments.
#[derive(Copy, Clone, PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TakesValue {
/// This flag has to be followed by a value.
@ -108,7 +108,7 @@ pub enum TakesValue {
/// An **argument** can be matched by one of the users input strings.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct Arg {
/// The short argument that matches it, if any.
@ -136,7 +136,7 @@ impl fmt::Display for Arg {
/// Literally just several args.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Args(pub &'static [&'static Arg]);
impl Args {
@ -340,7 +340,7 @@ impl Args {
/// The **matches** are the result of parsing the users command-line strings.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Matches<'args> {
/// The flags that were parsed from the users input.
@ -351,7 +351,7 @@ pub struct Matches<'args> {
pub frees: Vec<&'args OsStr>,
}
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct MatchedFlags<'args> {
/// The individual flags from the users input, in the order they were
@ -462,7 +462,7 @@ impl<'a> MatchedFlags<'a> {
/// A problem with the users input that meant it couldnt be parsed into a
/// coherent list of arguments.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub enum ParseError {
/// A flag that has to take a value was not given one.
@ -743,6 +743,6 @@ mod matches_test {
fn no_count() {
let flags = MatchedFlags { flags: Vec::new(), strictness: Strictness::UseLastArguments };
assert_eq!(flags.has(&COUNT).unwrap(), false);
assert!(!flags.has(&COUNT).unwrap());
}
}

View File

@ -130,18 +130,18 @@ mod terminal_test {
impl MockVars {
fn empty() -> MockVars {
return MockVars {
MockVars {
ls: "",
exa: "",
no_color: "",
};
}
}
fn with_no_color() -> MockVars {
return MockVars {
MockVars {
ls: "",
exa: "",
no_color: "true",
};
}
}
}

View File

@ -8,7 +8,7 @@ use crate::options::flags;
use crate::options::parser::MatchedFlags;
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct VersionString;
// There were options here once, but there arent anymore!

View File

@ -378,7 +378,7 @@ mod test {
($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => {
/// Special macro for testing Err results.
/// This is needed because sometimes the Ok type doesnt implement PartialEq.
/// This is needed because sometimes the Ok type doesnt implement `PartialEq`.
#[test]
fn $name() {
for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
@ -389,7 +389,7 @@ mod test {
($name:ident: $type:ident <- $inputs:expr; $stricts:expr => like $pat:pat) => {
/// More general macro for testing against a pattern.
/// Instead of using PartialEq, this just tests if it matches a pat.
/// Instead of using `PartialEq`, this just tests if it matches a pat.
#[test]
fn $name() {
for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {

View File

@ -77,11 +77,9 @@ impl TextCell {
///
/// This method allocates a `String` to hold the spaces.
pub fn add_spaces(&mut self, count: usize) {
use std::iter::repeat;
(*self.width) += count;
let spaces: String = repeat(' ').take(count).collect();
let spaces: String = " ".repeat(count);
self.contents.0.push(Style::default().paint(spaces));
}
@ -193,7 +191,7 @@ impl TextCellContents {
///
/// It has `From` impls that convert an input string or fixed with to values
/// of this type, and will `Deref` to the contained `usize` value.
#[derive(PartialEq, Debug, Clone, Copy, Default)]
#[derive(PartialEq, Eq, Debug, Clone, Copy, Default)]
pub struct DisplayWidth(usize);
impl<'a> From<&'a str> for DisplayWidth {

View File

@ -91,7 +91,7 @@ use crate::theme::Theme;
///
/// Almost all the heavy lifting is done in a Table object, which handles the
/// columns for each row.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Options {
/// Options specific to drawing a table.
@ -161,7 +161,7 @@ impl<'a> Render<'a> {
(None, _) => {/* Keep Git how it is */},
}
let mut table = Table::new(table, self.git, &self.theme);
let mut table = Table::new(table, self.git, self.theme);
if self.opts.header {
let header = table.header_row();

View File

@ -54,7 +54,7 @@ enum LinkStyle {
/// Whether to append file class characters to the file names.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum Classify {
/// Just display the file names, without any characters.
@ -73,7 +73,7 @@ impl Default for Classify {
/// Whether and how to show icons.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum ShowIcons {
/// Dont show icons at all.

View File

@ -8,7 +8,7 @@ use crate::output::file_name::Options as FileStyle;
use crate::theme::Theme;
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct Options {
pub across: bool,
}

View File

@ -18,7 +18,7 @@ use crate::output::tree::{TreeParams, TreeDepth};
use crate::theme::Theme;
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Options {
pub grid: GridOptions,
pub details: DetailsOptions,
@ -39,7 +39,7 @@ impl Options {
/// small directory of four files in four columns, the files just look spaced
/// out and its harder to see whats going on. So it can be enabled just for
/// larger directory listings.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum RowThreshold {
/// Only use grid-details view if it would result in at least this many
@ -202,7 +202,7 @@ impl<'a> Render<'a> {
(None, _) => {/* Keep Git how it is */},
}
let mut table = Table::new(options, self.git, &self.theme);
let mut table = Table::new(options, self.git, self.theme);
let mut rows = Vec::new();
if self.details.header {

View File

@ -26,7 +26,7 @@ pub struct View {
/// The **mode** is the “type” of output.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum Mode {
Grid(grid::Options),
@ -37,7 +37,7 @@ pub enum Mode {
/// The width of the terminal requested by the user.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TerminalWidth {
/// The user requested this specific number of columns.

View File

@ -43,7 +43,7 @@ pub mod test {
let blox = f::Blocks::None;
let expected = TextCell::blank(Green.italic());
assert_eq!(expected, blox.render(&TestColours).into());
assert_eq!(expected, blox.render(&TestColours));
}
@ -52,6 +52,6 @@ pub mod test {
let blox = f::Blocks::Some(3005);
let expected = TextCell::paint_str(Red.blink(), "3005");
assert_eq!(expected, blox.render(&TestColours).into());
assert_eq!(expected, blox.render(&TestColours));
}
}

View File

@ -85,7 +85,7 @@ pub mod test {
].into(),
};
assert_eq!(expected, stati.render(&TestColours).into())
assert_eq!(expected, stati.render(&TestColours))
}
@ -104,6 +104,6 @@ pub mod test {
].into(),
};
assert_eq!(expected, stati.render(&TestColours).into())
assert_eq!(expected, stati.render(&TestColours))
}
}

View File

@ -21,8 +21,8 @@ pub mod test {
#[test]
fn blocklessness() {
let io = f::Inode(1414213);
let io = f::Inode(1_414_213);
let expected = TextCell::paint_str(Cyan.underline(), "1414213");
assert_eq!(expected, io.render(Cyan.underline()).into());
assert_eq!(expected, io.render(Cyan.underline()));
}
}

View File

@ -52,7 +52,7 @@ pub mod test {
contents: vec![ Blue.paint("1") ].into(),
};
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into());
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
}
#[test]
@ -67,7 +67,7 @@ pub mod test {
contents: vec![ Blue.paint("3,005") ].into(),
};
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into());
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
}
#[test]
@ -82,6 +82,6 @@ pub mod test {
contents: vec![ Blue.on(Red).paint("3,005") ].into(),
};
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into());
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
}
}

View File

@ -6,7 +6,7 @@ use crate::output::cell::TextCell;
impl f::OctalPermissions {
fn bits_to_octal(r: bool, w: bool, x: bool) -> u8 {
(r as u8) * 4 + (w as u8) * 2 + (x as u8)
u8::from(r) * 4 + u8::from(w) * 2 + u8::from(x)
}
pub fn render(&self, style: Style) -> TextCell {
@ -40,7 +40,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0755");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -54,7 +54,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0644");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -68,7 +68,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0600");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -82,7 +82,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "4777");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
@ -97,7 +97,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "2777");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -111,6 +111,6 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "1777");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
}

View File

@ -153,7 +153,7 @@ pub mod test {
#[test]
fn file_bytes() {
let directory = f::Size::Some(1048576);
let directory = f::Size::Some(1_048_576);
let expected = TextCell {
width: DisplayWidth::from(9),
contents: vec![

View File

@ -21,7 +21,7 @@ use crate::theme::Theme;
/// Options for displaying a table.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Options {
pub size_format: SizeFormat,
pub time_format: TimeFormat,
@ -31,7 +31,7 @@ pub struct Options {
/// Extra columns to display in the table.
#[allow(clippy::struct_excessive_bools)]
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub struct Columns {
/// At least one of these timestamps will be shown.
@ -200,8 +200,8 @@ impl Column {
/// Formatting options for file sizes.
#[allow(clippy::pub_enum_variant_names)]
#[derive(PartialEq, Debug, Copy, Clone)]
#[allow(clippy::enum_variant_names)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SizeFormat {
/// Format the file size using **decimal** prefixes, such as “kilo”,
@ -217,7 +217,7 @@ pub enum SizeFormat {
}
/// Formatting options for user and group.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum UserFormat {
/// The UID / GID
Numeric,
@ -234,7 +234,7 @@ impl Default for SizeFormat {
/// The types of a files time fields. These three fields are standard
/// across most (all?) operating systems.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TimeType {
/// The files modified time (`st_mtime`).
@ -269,7 +269,7 @@ impl TimeType {
///
/// There should always be at least one of these — theres no way to disable
/// the time columns entirely (yet).
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[allow(clippy::struct_excessive_bools)]
pub struct TimeTypes {
pub modified: bool,
@ -347,7 +347,7 @@ fn determine_time_zone() -> TZResult<TimeZone> {
} else {
format!("/usr/share/zoneinfo/{}", {
if file.starts_with(':') {
file.replacen(":", "", 1)
file.replacen(':', "", 1)
} else {
file
}

View File

@ -25,7 +25,7 @@ use unicode_width::UnicodeWidthStr;
///
/// Currently exa does not support *custom* styles, where the user enters a
/// format string in an environment variable or something. Just these four.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TimeFormat {
/// The **default format** uses the users locale to print month names,
@ -87,7 +87,7 @@ fn default_zoned(time: SystemTime, zone: &TimeZone) -> String {
}
fn get_dateformat(date: &LocalDateTime) -> &'static DateFormat<'static> {
match (is_recent(&date), *MAXIMUM_MONTH_WIDTH) {
match (is_recent(date), *MAXIMUM_MONTH_WIDTH) {
(true, 4) => &FOUR_WIDE_DATE_TIME,
(true, 5) => &FIVE_WIDE_DATE_TIME,
(true, _) => &OTHER_WIDE_DATE_TIME,

View File

@ -39,7 +39,7 @@
//! each directory)
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum TreePart {
/// Rightmost column, *not* the last in the directory.
@ -253,19 +253,19 @@ mod iter_test {
#[test]
fn test_iteration() {
let foos = &[ "first", "middle", "last" ];
let mut iter = TreeDepth::root().iterate_over(foos.into_iter());
let mut iter = TreeDepth::root().iterate_over(foos.iter());
let next = iter.next().unwrap();
assert_eq!(&"first", next.1);
assert_eq!(false, next.0.last);
assert!(!next.0.last);
let next = iter.next().unwrap();
assert_eq!(&"middle", next.1);
assert_eq!(false, next.0.last);
assert!(!next.0.last);
let next = iter.next().unwrap();
assert_eq!(&"last", next.1);
assert_eq!(true, next.0.last);
assert!(next.0.last);
assert!(iter.next().is_none());
}
@ -273,7 +273,7 @@ mod iter_test {
#[test]
fn test_empty() {
let nothing: &[usize] = &[];
let mut iter = TreeDepth::root().iterate_over(nothing.into_iter());
let mut iter = TreeDepth::root().iterate_over(nothing.iter());
assert!(iter.next().is_none());
}
}

View File

@ -14,7 +14,7 @@ pub use self::lsc::LSColors;
mod default_theme;
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Eq, Debug)]
pub struct Options {
pub use_colours: UseColours,
@ -31,7 +31,7 @@ pub struct Options {
/// Turning them on when output is going to, say, a pipe, would make programs
/// such as `grep` or `more` not work properly. So the `Automatic` mode does
/// this check and only displays colours when they can be truly appreciated.
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum UseColours {
/// Display them even when output isnt going to a terminal.
@ -44,13 +44,13 @@ pub enum UseColours {
Never,
}
#[derive(PartialEq, Debug, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum ColourScale {
Fixed,
Gradient,
}
#[derive(PartialEq, Debug, Default)]
#[derive(PartialEq, Eq, Debug, Default)]
pub struct Definitions {
pub ls: Option<String>,
pub exa: Option<String>,
@ -262,11 +262,11 @@ impl render::SizeColours for Theme {
use number_prefix::Prefix::*;
match prefix {
None => self.ui.size.number_byte,
Some(Kilo) | Some(Kibi) => self.ui.size.number_kilo,
Some(Mega) | Some(Mebi) => self.ui.size.number_mega,
Some(Giga) | Some(Gibi) => self.ui.size.number_giga,
Some(_) => self.ui.size.number_huge,
Some(Kilo | Kibi) => self.ui.size.number_kilo,
Some(Mega | Mebi) => self.ui.size.number_mega,
Some(Giga | Gibi) => self.ui.size.number_giga,
Some(_) => self.ui.size.number_huge,
None => self.ui.size.number_byte,
}
}
@ -274,11 +274,11 @@ impl render::SizeColours for Theme {
use number_prefix::Prefix::*;
match prefix {
None => self.ui.size.unit_byte,
Some(Kilo) | Some(Kibi) => self.ui.size.unit_kilo,
Some(Mega) | Some(Mebi) => self.ui.size.unit_mega,
Some(Giga) | Some(Gibi) => self.ui.size.unit_giga,
Some(_) => self.ui.size.unit_huge,
Some(Kilo | Kibi) => self.ui.size.unit_kilo,
Some(Mega | Mebi) => self.ui.size.unit_mega,
Some(Giga | Gibi) => self.ui.size.unit_giga,
Some(_) => self.ui.size.unit_huge,
None => self.ui.size.unit_byte,
}
}