konst::string

Function is_char_boundary

Source
pub const fn is_char_boundary(string: &str, position: usize) -> bool
Expand description

Const equivalent of str::is_char_boundary.

ยงExample

use konst::string::is_char_boundary;

let string =  "้”ˆ is ๐Ÿง ";

// Start of "้”ˆ"
assert!(is_char_boundary(string, 0));
assert!(!is_char_boundary(string, 1));
assert!(!is_char_boundary(string, 2));

// start of " "
assert!(is_char_boundary(string, 3));

// start of "๐Ÿง "
assert!(is_char_boundary(string, 7));
assert!(!is_char_boundary(string, 8));

// end of string
assert!(is_char_boundary(string, string.len()));

// after end of string
assert!(!is_char_boundary(string, string.len() + 1));