Function konst::string::char_indices
source · pub const fn char_indices(string: &str) -> CharIndices<'_>
Expand description
Cosnt equivalent of str::char_indices
.
§Example
use konst::string;
use konst::iter::collect_const;
const CHARS: &[(usize, char)] =
&collect_const!((usize, char) => string::char_indices("个bar人"));
const REV: &[(usize, char)] =
&collect_const!((usize, char) => string::char_indices("个bar人").rev());
assert_eq!(CHARS, &[(0, '个'), (3, 'b'), (4, 'a'), (5, 'r'), (6, '人')]);
assert_eq!(REV, &[(6, '人'), (5, 'r'), (4, 'a'), (3, 'b'), (0, '个')]);