Expand description
This module contains object which can be used to limit a cell to a given width:
Truncate
cuts a cell content to limit width.Wrap
split the content via new lines in order to fit max width.Justify
sets columns width to the same value.
To set a a table width, a combination of Width::truncate
or Width::wrap
and Width::increase
can be used.
§Example
use tabled::{Width, Table};
let table = Table::new(&["Hello World!"])
.with(Width::wrap(7))
.with(Width::increase(7))
.to_string();
assert_eq!(
table,
concat!(
"+-----+\n",
"| &st |\n",
"| r |\n",
"+-----+\n",
"| Hel |\n",
"| lo |\n",
"| Wor |\n",
"| ld! |\n",
"+-----+",
)
);
Structs§
- Justify sets all columns widths to the set value.
MinWidth
changes a content in case if it’s length is lower then the boundary.- Truncate cut the string to a given width if its length exceeds it. Otherwise keeps the content of a cell untouched.
- Width allows you to set a min and max width of an object on a
Table
using different strategies. - A structure used to set
Table
width via a list of columns widths. - Wrap wraps a string to a new line in case it exceeds the provided max boundary. Otherwise keeps the content of a cell untouched.
Enums§
- A suffix limit settings.