Skip to content

Commit

Permalink
tabled/ depricate Style::default use Style::ascii instead
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
  • Loading branch information
zhiburt committed Nov 20, 2021
1 parent 356f477 commit c39b501
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -248,7 +248,7 @@ impl Table {
let grid = build_grid(iter);

let table = Self { grid };
table.with(Style::default())
table.with(Style::ascii())
}

/// With is a generic function which applies options to the [Table].
Expand Down
18 changes: 18 additions & 0 deletions src/style.rs
Expand Up @@ -47,7 +47,25 @@ impl Style {
/// | 3 | Endeavouros | https://endeavouros.com/ |
/// +----+--------------+---------------------------+
/// ```
#[deprecated(note = "The name is not explicit. Use ascii function instead.")]
pub fn default() -> Self {
Self::ascii()
}

/// Ascii style looks like the following table
///
/// ```text
/// +----+--------------+---------------------------+
/// | id | destribution | link |
/// +----+--------------+---------------------------+
/// | 0 | Fedora | https://getfedora.org/ |
/// +----+--------------+---------------------------+
/// | 2 | OpenSUSE | https://www.opensuse.org/ |
/// +----+--------------+---------------------------+
/// | 3 | Endeavouros | https://endeavouros.com/ |
/// +----+--------------+---------------------------+
/// ```
pub fn ascii() -> Self {
let line = Line::bordered('-', '+', '+', '+');

Self::new(
Expand Down
2 changes: 1 addition & 1 deletion tests/alignment_test.rs
Expand Up @@ -76,7 +76,7 @@ fn head_and_data_alignment() {
);

let table = Table::new(&data)
.with(Style::default())
.with(Style::ascii())
.with(Modify::new(Head).with(Alignment::left()))
.with(Modify::new(Row(1..)).with(Alignment::right()))
.to_string();
Expand Down
2 changes: 1 addition & 1 deletion tests/disable_test.rs
Expand Up @@ -36,7 +36,7 @@ fn disable_rows() {
);

let table = Table::new(&data)
.with(Style::default())
.with(Style::ascii())
.with(Modify::new(Full).with(Alignment::left()))
.with(Disable::Row(1..=2))
.to_string();
Expand Down
4 changes: 2 additions & 2 deletions tests/rotate_test.rs
Expand Up @@ -155,7 +155,7 @@ fn rotate_preserve_border_styles_test() {
let data = [(123, 456, 789), (234, 567, 891), (111, 222, 333)];

let table = Table::new(&data)
.with(Style::default())
.with(Style::ascii())
.with(Highlight::row(0, Border::default().top('*')))
.with(Rotate::Left)
.to_string();
Expand All @@ -174,7 +174,7 @@ fn rotate_preserve_border_styles_test() {
);

let table = Table::new(&data)
.with(Style::default())
.with(Style::ascii())
.with(Highlight::cell(0, 2, Border::default().bottom('*')))
.with(Rotate::Left)
.to_string();
Expand Down
2 changes: 1 addition & 1 deletion tests/style_test.rs
Expand Up @@ -40,7 +40,7 @@ fn default_style() {
"+----+--------------+---------------------------+\n",
);

let table = Table::new(&data).with(Style::default()).to_string();
let table = Table::new(&data).with(Style::ascii()).to_string();

assert_eq!(table, expected);
}
Expand Down

0 comments on commit c39b501

Please sign in to comment.