pub struct CleanCharset;
Expand description
CleanCharset
removes all \t
and \r
occurrences.
§Example
use std::iter::FromIterator;
use tabled::{
Table, builder::Builder,
settings::formatting::Charset,
};
let text = "Some text which was created on windows \r\n yes they use this \\r\\n";
let mut builder = Builder::from(Table::from_iter([[text]]));
builder.insert_record(0, ["win. text"]);
let mut table = builder.build();
table.with(Charset::clean());
assert_eq!(
table.to_string(),
"+-----------------------------------------+\n\
| win. text |\n\
+-----------------------------------------+\n\
| Some text which was created on windows |\n\
| yes they use this \\r\\n |\n\
+-----------------------------------------+"
)
Implementations§
Source§impl CleanCharset
impl CleanCharset
Sourcepub fn clean(s: &str) -> Cow<'_, str>
pub fn clean(s: &str) -> Cow<'_, str>
Removes all symbols which may break the layout such as \t
, \r
and more.
Notice that tab is just removed rather then being replaced with spaces.
§Example
use tabled::settings::formatting::CleanCharset;
assert_eq!(
CleanCharset::clean("Some\ttext\t\twith \\tabs\r\nSome"),
"Sometextwith \\tabs\nSome"
)
Trait Implementations§
Source§impl<R, C> CellOption<R, C> for CleanCharset
impl<R, C> CellOption<R, C> for CleanCharset
Source§impl Clone for CleanCharset
impl Clone for CleanCharset
Source§fn clone(&self) -> CleanCharset
fn clone(&self) -> CleanCharset
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CleanCharset
impl Debug for CleanCharset
Source§impl Default for CleanCharset
impl Default for CleanCharset
Source§fn default() -> CleanCharset
fn default() -> CleanCharset
Returns the “default value” for a type. Read more
Source§impl<R, D, C> TableOption<R, C, D> for CleanCharset
impl<R, D, C> TableOption<R, C, D> for CleanCharset
Auto Trait Implementations§
impl Freeze for CleanCharset
impl RefUnwindSafe for CleanCharset
impl Send for CleanCharset
impl Sync for CleanCharset
impl Unpin for CleanCharset
impl UnwindSafe for CleanCharset
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