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::{Table, settings::{object::Segment, width::Width, Modify}};
let table = Table::new(&["Hello World!"])
.with(Modify::new(Segment::all()).with(Width::wrap(3)));
Implementations§
Source§impl<W> Wrap<W>
impl<W> Wrap<W>
Sourcepub fn new(width: W) -> Selfwhere
W: Measurement<Width>,
pub fn new(width: W) -> Selfwhere
W: Measurement<Width>,
Creates a Wrap
object
Source§impl<W, P> Wrap<W, P>
impl<W, P> Wrap<W, P>
Sourcepub fn priority<PP: Peaker>(self, priority: PP) -> Wrap<W, PP>
pub fn priority<PP: Peaker>(self, priority: PP) -> 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, on: bool) -> Self
pub fn keep_words(self, on: bool) -> 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, R, P> CellOption<R, ColoredConfig> for Wrap<W, P>where
W: Measurement<Width>,
R: Records + ExactRecords + PeekableRecords + RecordsMut<String>,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
impl<W, R, P> CellOption<R, ColoredConfig> for Wrap<W, P>where
W: Measurement<Width>,
R: Records + ExactRecords + PeekableRecords + RecordsMut<String>,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, entity: Entity)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, entity: Entity)
Modification function of a certail part of a grid targeted by
Entity
.Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl<W, P, R> TableOption<R, ColoredConfig, CompleteDimension> for Wrap<W, P>where
W: Measurement<Width>,
P: Peaker,
R: Records + ExactRecords + PeekableRecords + RecordsMut<String>,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: Cell + AsRef<str>,
impl<W, P, R> TableOption<R, ColoredConfig, CompleteDimension> for Wrap<W, P>where
W: Measurement<Width>,
P: Peaker,
R: Records + ExactRecords + PeekableRecords + RecordsMut<String>,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: Cell + AsRef<str>,
Source§fn change(
self,
records: &mut R,
cfg: &mut ColoredConfig,
dims: &mut CompleteDimension,
)
fn change( self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut CompleteDimension, )
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreAuto Trait Implementations§
impl<W, P> Freeze for Wrap<W, P>
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