Trait similar::DiffableStr

source ·
pub trait DiffableStr: Hash + PartialEq + PartialOrd + Ord + Eq + ToOwned {
    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] ;

    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§

Splits the value into newlines with newlines attached.

Splits the value into newlines with newlines separated.

Tokenizes into words.

Tokenizes the input into characters.

Decodes the string (potentially) lossy.

Decodes the string (potentially) lossy.

Checks if the string ends in a newline.

The length of the string.

Slices the string.

Returns the string as slice of raw bytes.

Provided Methods§

Checks if the string is empty.

Implementations on Foreign Types§

Implementors§