StrExt

Trait StrExt 

Source
pub trait StrExt {
    // Required methods
    fn substr_pos(&self, substr: &Self) -> Option<Span>;
    fn char_length(&self, byte_index: usize) -> Option<usize>;
    fn char_span(&self, byte_index: usize) -> Option<Span>;
}

Required Methods§

Source

fn substr_pos(&self, substr: &Self) -> Option<Span>

Gets the position of a substring within a string.

§Example
let place = "mississippis";

let second_is: &str = place.matches("is").nth(1).unwrap();

assert_eq!(place.substr_pos(second_is), Some(Span::from(4..6)));
Source

fn char_length(&self, byte_index: usize) -> Option<usize>

Gets the length of the character starting at byte_index

Source

fn char_span(&self, byte_index: usize) -> Option<Span>

Gets the range of the character starting at byte_index

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 StrExt for str

Source§

fn substr_pos(&self, substr: &Self) -> Option<Span>

Source§

fn char_length(&self, byte_index: usize) -> Option<usize>

Source§

fn char_span(&self, byte_index: usize) -> Option<Span>

Implementors§