mirror of
https://github.com/uutils/uutils-term-grid.git
synced 2026-06-10 16:13:01 -07:00
clippy fixes
This commit is contained in:
+9
-9
@@ -119,7 +119,7 @@ pub enum Alignment {
|
||||
/// The easiest way to create a Cell is just by using `string.into()`, which
|
||||
/// uses the **unicode width** of the string (see the `unicode_width` crate).
|
||||
/// However, the fields are public, if you wish to provide your own length.
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub struct Cell {
|
||||
/// The string to display when this cell gets rendered.
|
||||
pub contents: String,
|
||||
@@ -144,7 +144,7 @@ impl From<String> for Cell {
|
||||
impl<'a> From<&'a str> for Cell {
|
||||
fn from(string: &'a str) -> Self {
|
||||
Self {
|
||||
width: UnicodeWidthStr::width(&*string),
|
||||
width: UnicodeWidthStr::width(string),
|
||||
contents: string.into(),
|
||||
alignment: Alignment::Left,
|
||||
}
|
||||
@@ -152,7 +152,7 @@ impl<'a> From<&'a str> for Cell {
|
||||
}
|
||||
|
||||
/// Direction cells should be written in — either across, or downwards.
|
||||
#[derive(PartialEq, Debug, Copy, Clone)]
|
||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
||||
pub enum Direction {
|
||||
/// Starts at the top left and moves rightwards, going back to the first
|
||||
/// column for a new row, like a typewriter.
|
||||
@@ -168,7 +168,7 @@ pub type Width = usize;
|
||||
|
||||
/// The text to put in between each pair of columns.
|
||||
/// This does not include any spaces used when aligning cells.
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum Filling {
|
||||
/// A certain number of spaces should be used as the separator.
|
||||
Spaces(Width),
|
||||
@@ -189,7 +189,7 @@ impl Filling {
|
||||
|
||||
/// The user-assignable options for a grid view that should be passed to
|
||||
/// [`Grid::new()`](struct.Grid.html#method.new).
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct GridOptions {
|
||||
/// The direction that the cells should be written in — either
|
||||
/// across, or downwards.
|
||||
@@ -199,7 +199,7 @@ pub struct GridOptions {
|
||||
pub filling: Filling,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
struct Dimensions {
|
||||
/// The number of lines in the grid.
|
||||
num_lines: Width,
|
||||
@@ -224,7 +224,7 @@ impl Dimensions {
|
||||
/// Everything needed to format the cells with the grid options.
|
||||
///
|
||||
/// For more information, see the [`term_grid` crate documentation](index.html).
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct Grid {
|
||||
options: GridOptions,
|
||||
cells: Vec<Cell>,
|
||||
@@ -412,7 +412,7 @@ impl Grid {
|
||||
///
|
||||
/// This type implements `Display`, so you can get the textual version
|
||||
/// of the grid by calling `.to_string()`.
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct Display<'grid> {
|
||||
/// The grid to display.
|
||||
grid: &'grid Grid,
|
||||
@@ -520,7 +520,7 @@ impl fmt::Display for Display<'_> {
|
||||
|
||||
/// Pad a string with the given number of spaces.
|
||||
fn spaces(length: usize) -> String {
|
||||
repeat(" ").take(length).collect()
|
||||
" ".repeat(length)
|
||||
}
|
||||
|
||||
/// Pad a string with the given alignment and number of spaces.
|
||||
|
||||
+3
-3
@@ -46,7 +46,7 @@ fn one_item_just_over() {
|
||||
|
||||
grid.add(Cell::from("1234567890!"));
|
||||
|
||||
assert_eq!(grid.fit_into_width(10), None);
|
||||
assert!(grid.fit_into_width(10).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -95,7 +95,7 @@ fn two_big_items() {
|
||||
"oudisnuthasuouneohbueobaugceoduhbsauglcobeuhnaeouosbubaoecgueoubeohubeo",
|
||||
));
|
||||
|
||||
assert_eq!(grid.fit_into_width(40), None);
|
||||
assert!(grid.fit_into_width(40).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -188,7 +188,7 @@ fn huge_separator() {
|
||||
grid.add("a".into());
|
||||
grid.add("b".into());
|
||||
|
||||
assert_eq!(grid.fit_into_width(99), None);
|
||||
assert!(grid.fit_into_width(99).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user