Function konst::string::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));