I'm trying to get the unicodes from \u0300
to \u036f
as an array or a vector in Rust.
I tried several things but those haven't worked yet.
CodePudding user response:
You can create a range of char
s, and collect them into a Vec
:
Vec::from_iter('\u{0300}'..='\u{036f}')
Creating an array is a little more difficult, but also possible:
const LEN: usize = '\u{036f}' as usize - '\u{0300}' as usize;
let mut arr = ['\0'; LEN];
for (item, ch) in std::iter::zip(&mut arr, '\u{0300}'..='\u{036f}') {
*item = ch;
}