Skip to content

Commit

Permalink
Merge pull request #63 from danieleades/refactor/use-self
Browse files Browse the repository at this point in the history
use 'Self' to refer to own type
  • Loading branch information
Nukesor committed Jan 30, 2022
2 parents 0358051 + 4222f44 commit 12eadbe
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Cell {
/// Create a new Cell
#[allow(clippy::needless_pass_by_value)]
pub fn new<T: ToString>(content: T) -> Self {
Cell {
Self {
content: content
.to_string()
.split('\n')
Expand Down Expand Up @@ -152,8 +152,8 @@ impl Cell {
/// let cell: Cell = 5u32.into();
/// ```
impl<T: ToString> From<T> for Cell {
fn from(content: T) -> Cell {
Cell::new(content)
fn from(content: T) -> Self {
Self::new(content)
}
}

Expand All @@ -178,8 +178,8 @@ where
T: IntoIterator,
T::Item: Into<Cell>,
{
fn from(cells: T) -> Cells {
Cells(cells.into_iter().map(Into::into).collect())
fn from(cells: T) -> Self {
Self(cells.into_iter().map(Into::into).collect())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Column {

impl Column {
pub fn new(index: usize) -> Self {
Column {
Self {
index,
padding: (1, 1),
delimiter: None,
Expand Down
8 changes: 4 additions & 4 deletions src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub struct Row {
}

impl Row {
pub fn new() -> Row {
Row::default()
pub fn new() -> Self {
Self::default()
}

/// Add a cell to the row.
Expand Down Expand Up @@ -92,8 +92,8 @@ impl Row {
/// let row = Row::from(vec![1, 2, 3, 4]);
/// ```
impl<T: Into<Cells>> From<T> for Row {
fn from(cells: T) -> Row {
Row {
fn from(cells: T) -> Self {
Self {
index: None,
cells: cells.into().0,
max_height: None,
Expand Down
2 changes: 1 addition & 1 deletion src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Default for Table {
impl Table {
/// Create a new table with default ASCII styling.
pub fn new() -> Self {
let mut table = Table {
let mut table = Self {
columns: Vec::new(),
header: None,
rows: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ColumnDisplayInfo {
if content_width == 0 {
content_width = 1;
}
ColumnDisplayInfo {
Self {
padding: column.padding,
delimiter: column.delimiter,
content_width,
Expand Down

0 comments on commit 12eadbe

Please sign in to comment.