tabled::width

Struct Wrap

Source
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>,

Source

pub fn new(width: W) -> Self

Creates a Wrap object

Source§

impl<W, P> Wrap<W, P>

Source

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.

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.

Source

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>

Source§

fn change_cell(&mut self, table: &mut Table<R>, entity: Entity)

Modification function of a single cell.
Source§

impl<W: Clone, P: Clone> Clone for Wrap<W, P>

Source§

fn clone(&self) -> Wrap<W, P>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<W: Debug, P: Debug> Debug for Wrap<W, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W, P, R> TableOption<R> for Wrap<W, P>

Source§

fn change(&mut self, table: &mut Table<R>)

The function modifies a Grid object.

Auto Trait Implementations§

§

impl<W, P> Freeze for Wrap<W, P>
where W: Freeze,

§

impl<W, P> RefUnwindSafe for Wrap<W, P>

§

impl<W, P> Send for Wrap<W, P>
where W: Send, P: Send,

§

impl<W, P> Sync for Wrap<W, P>
where W: Sync, P: Sync,

§

impl<W, P> Unpin for Wrap<W, P>
where W: Unpin, P: Unpin,

§

impl<W, P> UnwindSafe for Wrap<W, P>
where W: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.