Skip to main content

StringExt

Trait StringExt 

Source
pub trait StringExt {
    // Required methods
    fn char_count(&self) -> u32;
    fn char_index(&self, offset: u32) -> usize;
    fn char_slice(&self, start: u32, end: u32) -> &str;
    fn char_slice_from(&self, start: u32) -> &str;
}
Expand description

Extension trait that adds methods used for working with Strings and &strs in terms of their UTF-8 characters, as opposed to bytes

Required Methods§

Source

fn char_count(&self) -> u32

Source

fn char_index(&self, offset: u32) -> usize

Source

fn char_slice(&self, start: u32, end: u32) -> &str

Source

fn char_slice_from(&self, start: u32) -> &str

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S> StringExt for S
where S: AsRef<str>,