pub struct Wrap<W = usize, P = PriorityNone> { /* private fields */ }
Expand description
Wrap wraps a string to a new line in case it exceeds the provided max boundary. Otherwise keeps the content of a cell untouched.
The function is color aware if a color
feature is on.
Be aware that it doesn’t consider padding.
So if you want to set a exact width you might need to use Padding
to set it to 0.
§Example
use tabled::{object::Segment, Width, Modify, Table};
let table = Table::new(&["Hello World!"])
.with(Modify::new(Segment::all()).with(Width::wrap(3)));
Implementations§
Source§impl<W> Wrap<W>where
W: Measurment<Width>,
impl<W> Wrap<W>where
W: Measurment<Width>,
Source§impl<W, P> Wrap<W, P>
impl<W, P> Wrap<W, P>
Sourcepub fn priority<PP>(self) -> Wrap<W, PP>
pub fn priority<PP>(self) -> Wrap<W, PP>
Priority defines the logic by which a truncate will be applied when is done for the whole table.
PriorityNone
which cuts the columns one after another.PriorityMax
cuts the biggest columns first.PriorityMin
cuts the lowest columns first.
Be aware that it doesn’t consider padding.
So if you want to set a exact width you might need to use Padding
to set it to 0.
Sourcepub fn keep_words(self) -> Self
pub fn keep_words(self) -> Self
Set the keep words option.
If a wrapping point will be in a word, Wrap
will
preserve a word (if possible) and wrap the string before it.
Trait Implementations§
Source§impl<W, P, R> CellOption<R> for Wrap<W, P>
impl<W, P, R> CellOption<R> for Wrap<W, P>
Source§fn change_cell(&mut self, table: &mut Table<R>, entity: Entity)
fn change_cell(&mut self, table: &mut Table<R>, entity: Entity)
Modification function of a single cell.
Source§impl<W, P, R> TableOption<R> for Wrap<W, P>
impl<W, P, R> TableOption<R> for Wrap<W, P>
Auto Trait Implementations§
impl<W, P> Freeze for Wrap<W, P>where
W: Freeze,
impl<W, P> RefUnwindSafe for Wrap<W, P>where
W: RefUnwindSafe,
P: RefUnwindSafe,
impl<W, P> Send for Wrap<W, P>
impl<W, P> Sync for Wrap<W, P>
impl<W, P> Unpin for Wrap<W, P>
impl<W, P> UnwindSafe for Wrap<W, P>where
W: UnwindSafe,
P: UnwindSafe,
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