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>
impl<L> Remove<L, TargetColumn>
Sourcepub fn column(locator: L) -> Self
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>
impl<L> Remove<L, TargetRow>
Sourcepub fn row(locator: L) -> Self
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, R, D, C> TableOption<R, C, D> for Remove<L, TargetColumn>
impl<L, R, D, C> TableOption<R, C, D> for Remove<L, TargetColumn>
Source§impl<L, R, D, C> TableOption<R, C, D> for Remove<L, TargetRow>
impl<L, R, D, C> TableOption<R, C, D> for Remove<L, TargetRow>
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>
impl<L, Target> Sync for Remove<L, Target>
impl<L, Target> Unpin for Remove<L, Target>
impl<L, Target> UnwindSafe for Remove<L, Target>where
L: UnwindSafe,
Target: 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