pub trait StrExt {
// Required methods
fn view(&self) -> StringView<'_>;
fn view_part(&self, start_idx: usize, end_idx: usize) -> StringView<'_>;
fn char_idx(&self, ch: Char<'_>) -> (usize, usize);
fn chars_in_place(&self) -> CharsInPlace<'_> ⓘ;
fn chars_in_place_mut(&mut self) -> CharsInPlaceMut<'_> ⓘ;
}Required Methods§
fn view(&self) -> StringView<'_>
fn view_part(&self, start_idx: usize, end_idx: usize) -> StringView<'_>
Sourcefn char_idx(&self, ch: Char<'_>) -> (usize, usize)
fn char_idx(&self, ch: Char<'_>) -> (usize, usize)
Byte index of this Char start & end inside base str.
use string_view::StrExt;
let text = "Hello World";
let mut chars = text.chars_in_place();
let first_char = chars.next().unwrap();
assert_eq!(first_char.as_str(), "H");
assert_eq!(text.char_idx(first_char), (0, 1));
let second_char = chars.next().unwrap();
assert_eq!(second_char.as_str(), "e");
assert_eq!(text.char_idx(second_char), (1, 2));fn chars_in_place(&self) -> CharsInPlace<'_> ⓘ
fn chars_in_place_mut(&mut self) -> CharsInPlaceMut<'_> ⓘ
Implementations on Foreign Types§
Source§impl StrExt for str
impl StrExt for str
Source§fn char_idx(&self, ch: Char<'_>) -> (usize, usize)
fn char_idx(&self, ch: Char<'_>) -> (usize, usize)
Byte index of this Char start & end inside base str.
use string_view::StrExt;
let text = "Hello World";
let mut chars = text.chars_in_place();
let first_char = chars.next().unwrap();
assert_eq!(first_char.as_str(), "H");
assert_eq!(text.char_idx(first_char), (0, 1));
let second_char = chars.next().unwrap();
assert_eq!(second_char.as_str(), "e");
assert_eq!(text.char_idx(second_char), (1, 2));