pub struct Priority;
Expand description
An abstract factory to construct different Peaker
methods.
use tabled::{
Table,
assert::assert_table,
settings::{Style, peaker::Priority, Width},
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::max(false)));
let output = table.to_string();
assert_table!(
output,
"┌───┬────┬────┐"
"│ & │ &s │ i3 │"
"│ s │ tr │ 2 │"
"│ t │ │ │"
"│ r │ │ │"
"├───┼────┼────┤"
"│ 1 │ He │ 10 │"
"│ │ ll │ 0 │"
"│ │ o │ │"
"├───┼────┼────┤"
"│ 2 │ Wo │ 10 │"
"│ │ rl │ 00 │"
"│ │ d │ │"
"└───┴────┴────┘"
);
Implementations§
Source§impl Priority
impl Priority
Sourcepub fn none() -> PriorityNone
pub fn none() -> PriorityNone
Returns a Peaker
which goes over list one by one,
in order from left to right with no prioritization,
just peaking each value after another.
use tabled::{
Table,
settings::{Style, peaker::Priority, Width},
assert::assert_table,
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::none()));
let output = table.to_string();
assert_table!(
output,
"┌───┬────┬────┐"
"│ & │ &s │ i3 │"
"│ s │ tr │ 2 │"
"│ t │ │ │"
"│ r │ │ │"
"├───┼────┼────┤"
"│ 1 │ He │ 10 │"
"│ │ ll │ 0 │"
"│ │ o │ │"
"├───┼────┼────┤"
"│ 2 │ Wo │ 10 │"
"│ │ rl │ 00 │"
"│ │ d │ │"
"└───┴────┴────┘"
);
Sourcepub fn min(right: bool) -> PriorityMin
pub fn min(right: bool) -> PriorityMin
Returns a Peaker
which goes over list peacking a minimum value,
and prioritizing a chosen side when equal values are met.
use tabled::{
Table,
settings::{Style, peaker::Priority, Width},
assert::assert_table,
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::min(true)));
let output = table.to_string();
assert_table!(
output,
"┌──┬───────┬──┐"
"│ │ &str │ │"
"├──┼───────┼──┤"
"│ │ Hello │ │"
"├──┼───────┼──┤"
"│ │ World │ │"
"└──┴───────┴──┘"
);
Sourcepub fn max(right: bool) -> PriorityMax
pub fn max(right: bool) -> PriorityMax
Returns a Peaker
which goes over list peacking a maximum value,
and prioritizing a chosen side when equal values are met.
use tabled::{
Table,
settings::{Style, peaker::Priority, Width},
assert::assert_table,
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::max(true)));
let output = table.to_string();
assert_table!(
output,
"┌────┬────┬───┐"
"│ &s │ &s │ i │"
"│ tr │ tr │ 3 │"
"│ │ │ 2 │"
"├────┼────┼───┤"
"│ 1 │ He │ 1 │"
"│ │ ll │ 0 │"
"│ │ o │ 0 │"
"├────┼────┼───┤"
"│ 2 │ Wo │ 1 │"
"│ │ rl │ 0 │"
"│ │ d │ 0 │"
"│ │ │ 0 │"
"└────┴────┴───┘"
);
Sourcepub fn left() -> PriorityLeft
pub fn left() -> PriorityLeft
Returns a Peaker
which goes over list peacking a left most value as far as possible.
use tabled::{
Table,
settings::{Style, peaker::Priority, Width},
assert::assert_table,
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::left()));
let output = table.to_string();
assert_table!(
output,
"┌──┬───┬──────┐"
"│ │ & │ i32 │"
"│ │ s │ │"
"│ │ t │ │"
"│ │ r │ │"
"├──┼───┼──────┤"
"│ │ H │ 100 │"
"│ │ e │ │"
"│ │ l │ │"
"│ │ l │ │"
"│ │ o │ │"
"├──┼───┼──────┤"
"│ │ W │ 1000 │"
"│ │ o │ │"
"│ │ r │ │"
"│ │ l │ │"
"│ │ d │ │"
"└──┴───┴──────┘"
);
Sourcepub fn right() -> PriorityRight
pub fn right() -> PriorityRight
Returns a Peaker
which goes over list peacking a right most value as far as possible.
use tabled::{
Table,
settings::{Style, peaker::Priority, Width},
assert::assert_table,
};
let data = [
("1", "Hello", 100),
("2", "World", 1000),
];
let mut table = Table::new(data);
table.with(Style::modern());
table.with(Width::wrap(15).priority(Priority::right()));
let output = table.to_string();
assert_table!(
output,
"┌──────┬───┬──┐"
"│ &str │ & │ │"
"│ │ s │ │"
"│ │ t │ │"
"│ │ r │ │"
"├──────┼───┼──┤"
"│ 1 │ H │ │"
"│ │ e │ │"
"│ │ l │ │"
"│ │ l │ │"
"│ │ o │ │"
"├──────┼───┼──┤"
"│ 2 │ W │ │"
"│ │ o │ │"
"│ │ r │ │"
"│ │ l │ │"
"│ │ d │ │"
"└──────┴───┴──┘"
);
Trait Implementations§
Source§impl Ord for Priority
impl Ord for Priority
Source§impl PartialOrd for Priority
impl PartialOrd for Priority
impl Copy for Priority
impl Eq for Priority
impl StructuralPartialEq for Priority
Auto Trait Implementations§
impl Freeze for Priority
impl RefUnwindSafe for Priority
impl Send for Priority
impl Sync for Priority
impl Unpin for Priority
impl UnwindSafe for Priority
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more