std-method
str::is_char_boundary
Check whether a byte offset can serve as the start or end of a valid slice. Zero and len are boundaries; interior bytes of a multi-byte scalar are not. Expected stdout (not executed): true false true Common mistake: Confusing scalar boundaries with grapheme boundaries.
Formal Syntax & Structure
rust syntaxrust
fn is_char_boundary(&self, index: usize) -> boolWorking Example
Example Snippetrust
fn main() { let text = "AشB"; println!("{} {} {}", text.is_char_boundary(1), text.is_char_boundary(2), text.is_char_boundary(4));}