Struct Remove

Source
pub struct Remove<L, Target> { /* private fields */ }
Expand description

Remove removes particular rows/columns from a Table.

It tries to keeps track of style changes which may occur. But it’s not guaranteed will be the way you would expect it to be.

Generally you should avoid use of Remove because it’s a slow function and modifies the underlying records. Providing correct data right away is better.

§Example

use tabled::{Table, settings::{Remove, object::Rows}};

let data = vec!["Hello", "World", "!!!"];

let table = Table::new(data).with(Remove::row(Rows::new(1..2))).to_string();

assert_eq!(
    table,
    "+-------+\n\
     | &str  |\n\
     +-------+\n\
     | World |\n\
     +-------+\n\
     | !!!   |\n\
     +-------+"
);

Implementations§

Source§

impl<L> Remove<L, TargetColumn>

Source

pub fn column(locator: L) -> Self

Remove columns.

Available locators are:

use tabled::{builder::Builder, settings::{Remove, location::ByColumnName, object::Columns}};

let mut builder = Builder::default();
builder.push_record(["col1", "col2", "col3"]);
builder.push_record(["Hello", "World", "1"]);

let table = builder.build()
    .with(Remove::column(ByColumnName::new("col3")))
    .to_string();

assert_eq!(
    table,
    "+-------+-------+\n\
     | col1  | col2  |\n\
     +-------+-------+\n\
     | Hello | World |\n\
     +-------+-------+"
);
Source§

impl<L> Remove<L, TargetRow>

Source

pub fn row(locator: L) -> Self

Remove rows.

Available locators are:

use tabled::{settings::{Remove, object::Rows}, builder::Builder};

let mut builder = Builder::default();
builder.push_record(["col1", "col2", "col3"]);
builder.push_record(["Hello", "World", "1"]);

let table = builder.build()
    .with(Remove::row(Rows::first()))
    .to_string();

assert_eq!(
    table,
    "+-------+-------+---+\n\
     | Hello | World | 1 |\n\
     +-------+-------+---+"
);

Trait Implementations§

Source§

impl<L: Debug, Target: Debug> Debug for Remove<L, Target>

Source§

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

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

impl<L, R, D, C> TableOption<R, C, D> for Remove<L, TargetColumn>
where L: Location<R, Coordinate = usize>, R: Records + Resizable,

Source§

fn change(self, records: &mut R, _: &mut C, _: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

impl<L, R, D, C> TableOption<R, C, D> for Remove<L, TargetRow>
where L: Location<R, Coordinate = usize>, R: ExactRecords + Resizable,

Source§

fn change(self, records: &mut R, _: &mut C, _: &mut D)

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more

Auto Trait Implementations§

§

impl<L, Target> Freeze for Remove<L, Target>
where L: Freeze,

§

impl<L, Target> RefUnwindSafe for Remove<L, Target>
where L: RefUnwindSafe, Target: RefUnwindSafe,

§

impl<L, Target> Send for Remove<L, Target>
where L: Send, Target: Send,

§

impl<L, Target> Sync for Remove<L, Target>
where L: Sync, Target: Sync,

§

impl<L, Target> Unpin for Remove<L, Target>
where L: Unpin, Target: Unpin,

§

impl<L, Target> UnwindSafe for Remove<L, Target>
where L: UnwindSafe, Target: 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> 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, 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.