pub trait DiffableStr:
Hash
+ PartialEq
+ PartialOrd
+ Ord
+ Eq
+ ToOwned {
// 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 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 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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl DiffableStr for str
impl DiffableStr for str
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 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] ⓘ
Source§impl DiffableStr for [u8]
Allows viewing ASCII compatible byte slices as strings.
impl DiffableStr for [u8]
Allows viewing ASCII compatible byte slices as strings.
Requires the bytes feature.