Trait similar::DiffableStr[][src]

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 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]; fn is_empty(&self) -> bool { ... } }

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

fn tokenize_lines(&self) -> Vec<&Self>[src]

Splits the value into newlines with newlines attached.

fn tokenize_lines_and_newlines(&self) -> Vec<&Self>[src]

Splits the value into newlines with newlines separated.

fn tokenize_words(&self) -> Vec<&Self>[src]

Tokenizes into words.

fn tokenize_chars(&self) -> Vec<&Self>[src]

Tokenizes the input into characters.

fn tokenize_unicode_words(&self) -> Vec<&Self>[src]

Tokenizes into unicode words.

fn tokenize_graphemes(&self) -> Vec<&Self>[src]

Tokenizes into unicode graphemes.

fn as_str(&self) -> Option<&str>[src]

Decodes the string (potentially) lossy.

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

Decodes the string (potentially) lossy.

fn ends_with_newline(&self) -> bool[src]

Checks if the string ends in a newline.

fn len(&self) -> usize[src]

The length of the string.

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

Slices the string.

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

Returns the string as slice of raw bytes.

Loading content...

Provided methods

fn is_empty(&self) -> bool[src]

Checks if the string is empty.

Loading content...

Implementations on Foreign Types

impl DiffableStr for str[src]

impl DiffableStr for [u8][src]

Allows viewing ASCII compatible byte slices as strings.

Requires the bytes feature.

Loading content...

Implementors

Loading content...