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§
Sourcefn substr_pos(&self, substr: &Self) -> Option<Span>
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)));Sourcefn char_length(&self, byte_index: usize) -> Option<usize>
fn char_length(&self, byte_index: usize) -> Option<usize>
Gets the length 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.