Expand description
This module contains object which can be used to limit a cell to a given width:
Truncatecuts a cell content to limit width.Wrapsplit the content via new lines in order to fit max width.Justifysets 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::{Table, settings::Width};
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
- Justify sets all columns widths to the set value.
- MinWidth
MinWidthchanges a content in case if it’s length is lower then the boundary.- Truncate
- Truncate cut the string to a given width if its length exceeds it. Otherwise keeps the content of a cell untouched.
- Width
- Width allows you to set a min and max width of an object on a
Tableusing different strategies. - Width
List - A structure used to set
Tablewidth via a list of columns widths. - Wrap
- 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§
- Suffix
Limit - A suffix limit settings.