Trait similar::DiffableStr
source · pub trait DiffableStr: Hash + PartialEq + PartialOrd + Ord + Eq + ToOwned {
Show 13 methods
// Required methods
fn tokenize_lines(&self) -> Vec<&Self>;
fn tokenize_lines_and_newlines(&self) -> Vec<&Self>;
fn tokenize_words(&self) -> Vec<&Self>;
fn tokenize_chars(&self) -> Vec<&Self>;
fn tokenize_unicode_words(&self) -> Vec<&Self>;
fn tokenize_graphemes(&self) -> Vec<&Self>;
fn as_str(&self) -> Option<&str>;
fn to_string_lossy(&self) -> Cow<'_, str>;
fn ends_with_newline(&self) -> bool;
fn len(&self) -> usize;
fn slice(&self, rng: Range<usize>) -> &Self;
fn as_bytes(&self) -> &[u8] ⓘ;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
All supported diffable strings.
The text module can work with different types of strings depending
on how the crate is compiled. Out of the box &str
is always supported
but with the bytes
feature one can also work with [u8]
slices for
as long as they are ASCII compatible.
Requires the text
feature.
Required Methods§
sourcefn tokenize_lines(&self) -> Vec<&Self>
fn tokenize_lines(&self) -> Vec<&Self>
Splits the value into newlines with newlines attached.
sourcefn tokenize_lines_and_newlines(&self) -> Vec<&Self>
fn tokenize_lines_and_newlines(&self) -> Vec<&Self>
Splits the value into newlines with newlines separated.
sourcefn tokenize_words(&self) -> Vec<&Self>
fn tokenize_words(&self) -> Vec<&Self>
Tokenizes into words.
sourcefn tokenize_chars(&self) -> Vec<&Self>
fn tokenize_chars(&self) -> Vec<&Self>
Tokenizes the input into characters.
sourcefn tokenize_unicode_words(&self) -> Vec<&Self>
fn tokenize_unicode_words(&self) -> Vec<&Self>
Tokenizes into unicode words.
sourcefn tokenize_graphemes(&self) -> Vec<&Self>
fn tokenize_graphemes(&self) -> Vec<&Self>
Tokenizes into unicode graphemes.
sourcefn to_string_lossy(&self) -> Cow<'_, str>
fn to_string_lossy(&self) -> Cow<'_, str>
Decodes the string (potentially) lossy.
sourcefn ends_with_newline(&self) -> bool
fn ends_with_newline(&self) -> bool
Checks if the string ends in a newline.
Provided Methods§
Object Safety§
This trait is not object safe.