pub struct Height;
Available on crate feature
std
only.Expand description
Height is a abstract factory for height settings.
Example
use tabled::{Table, settings::{Height, Settings}};
let data = vec![
("Some data", "here", "and here"),
("Some data on a next", "line", "right here"),
];
let table = Table::new(data)
.with(Settings::new(Height::limit(10), Height::increase(10)))
.to_string();
assert_eq!(
table,
"+---------------------+------+------------+\n\
| &str | &str | &str |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data | here | and here |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data on a next | line | right here |\n\
| | | |\n\
+---------------------+------+------------+",
)
Implementations§
source§impl Height
impl Height
sourcepub fn increase<W: Measurement<Height>>(height: W) -> CellHeightIncrease<W>
pub fn increase<W: Measurement<Height>>(height: W) -> CellHeightIncrease<W>
Create CellHeightIncrease
to set a table/cell height.
Example
Cell height
use tabled::{Table, settings::{Height, Modify, object::Columns}};
let data = vec![
("Some data", "here", "and here"),
("Some data on a next", "line", "right here"),
];
let table = Table::new(data)
.with(Modify::new(Columns::first()).with(Height::increase(5)))
.to_string();
assert_eq!(
table,
"+---------------------+------+------------+\n\
| &str | &str | &str |\n\
| | | |\n\
| | | |\n\
| | | |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data | here | and here |\n\
| | | |\n\
| | | |\n\
| | | |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data on a next | line | right here |\n\
| | | |\n\
| | | |\n\
| | | |\n\
| | | |\n\
+---------------------+------+------------+"
)
Table height
use tabled::{Table, settings::Height};
let data = vec![
("Some data", "here", "and here"),
("Some data on a next", "line", "right here"),
];
let table = Table::new(data)
.with(Height::increase(10))
.to_string();
assert_eq!(
table,
"+---------------------+------+------------+\n\
| &str | &str | &str |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data | here | and here |\n\
| | | |\n\
+---------------------+------+------------+\n\
| Some data on a next | line | right here |\n\
| | | |\n\
+---------------------+------+------------+",
)
sourcepub fn limit<W: Measurement<Height>>(height: W) -> CellHeightLimit<W>
pub fn limit<W: Measurement<Height>>(height: W) -> CellHeightLimit<W>
Create CellHeightLimit
to set a table/cell height.
Example
Cell height
use tabled::{Table, settings::{Height, Modify, object::Columns}};
let data = vec![
("Some\ndata", "here", "and here"),
("Some\ndata on a next", "line", "right here"),
];
let table = Table::new(data)
.with(Modify::new(Columns::first()).with(Height::limit(1)))
.to_string();
assert_eq!(
table,
"+------+------+------------+\n\
| &str | &str | &str |\n\
+------+------+------------+\n\
| Some | here | and here |\n\
+------+------+------------+\n\
| Some | line | right here |\n\
+------+------+------------+"
)
Table height
use tabled::{Table, settings::Height};
let data = vec![
("Some\ndata", "here", "and here"),
("Some\ndata on a next", "line", "right here"),
];
let table = Table::new(&data)
.with(Height::limit(6))
.to_string();
assert_eq!(
table,
"+------+------+------------+\n\
+------+------+------------+\n\
| Some | here | and here |\n\
+------+------+------------+\n\
| Some | line | right here |\n\
+------+------+------------+",
);
let table = Table::new(&data)
.with(Height::limit(1))
.to_string();
assert_eq!(
table,
"+--+--+--+\n\
+--+--+--+\n\
+--+--+--+\n\
+--+--+--+",
);
sourcepub fn list<I: IntoIterator<Item = usize>>(rows: I) -> HeightList
pub fn list<I: IntoIterator<Item = usize>>(rows: I) -> HeightList
Create HeightList
to set a table height to a constant list of row heights.
Notice if you provide a list with .len()
less than Table::count_rows
then it will have no affect.
Example
use tabled::{Table, settings::{Height, Modify, object::Columns}};
let data = vec![
("Some\ndata", "here", "and here"),
("Some\ndata on a next", "line", "right here"),
];
let table = Table::new(data)
.with(Height::list([1, 0, 2]))
.to_string();
assert_eq!(
table,
"+----------------+------+------------+\n\
| &str | &str | &str |\n\
+----------------+------+------------+\n\
+----------------+------+------------+\n\
| Some | line | right here |\n\
| data on a next | | |\n\
+----------------+------+------------+",
)
Trait Implementations§
source§impl Measurement<Height> for Max
impl Measurement<Height> for Max
source§fn measure<R: Records + ExactRecords + PeekableRecords>(
&self,
records: R,
_: &SpannedConfig
) -> usize
fn measure<R: Records + ExactRecords + PeekableRecords>( &self, records: R, _: &SpannedConfig ) -> usize
Returns a measurement value.
source§impl Measurement<Height> for Min
impl Measurement<Height> for Min
source§fn measure<R: Records + ExactRecords + PeekableRecords>(
&self,
records: R,
_: &SpannedConfig
) -> usize
fn measure<R: Records + ExactRecords + PeekableRecords>( &self, records: R, _: &SpannedConfig ) -> usize
Returns a measurement value.
source§impl Measurement<Height> for Percent
impl Measurement<Height> for Percent
source§fn measure<R>(&self, records: R, cfg: &SpannedConfig) -> usize
fn measure<R>(&self, records: R, cfg: &SpannedConfig) -> usize
Returns a measurement value.
Auto Trait Implementations§
impl RefUnwindSafe for Height
impl Send for Height
impl Sync for Height
impl Unpin for Height
impl UnwindSafe for Height
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