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§

source

fn tokenize_lines(&self) -> Vec<&Self>

Splits the value into newlines with newlines attached.

source

fn tokenize_lines_and_newlines(&self) -> Vec<&Self>

Splits the value into newlines with newlines separated.

source

fn tokenize_words(&self) -> Vec<&Self>

Tokenizes into words.

source

fn tokenize_chars(&self) -> Vec<&Self>

Tokenizes the input into characters.

source

fn tokenize_unicode_words(&self) -> Vec<&Self>

Tokenizes into unicode words.

source

fn tokenize_graphemes(&self) -> Vec<&Self>

Tokenizes into unicode graphemes.

source

fn as_str(&self) -> Option<&str>

Decodes the string (potentially) lossy.

source

fn to_string_lossy(&self) -> Cow<'_, str>

Decodes the string (potentially) lossy.

source

fn ends_with_newline(&self) -> bool

Checks if the string ends in a newline.

source

fn len(&self) -> usize

The length of the string.

source

fn slice(&self, rng: Range<usize>) -> &Self

Slices the string.

source

fn as_bytes(&self) -> &[u8]

Returns the string as slice of raw bytes.

Provided Methods§

source

fn is_empty(&self) -> bool

Checks if the string is empty.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl DiffableStr for str

Implementors§