similar

Trait 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.

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn ends_with_newline(&self) -> bool

Source§

fn len(&self) -> usize

Source§

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

Source§

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

Implementors§