📅  最后修改于: 2022-03-11 14:58:22.404000             🧑  作者: Mango
If you want just the first char, then don't collect into a Vec, just use the iterator:
let text = "hello world!";
let ch = text.chars().next().unwrap();
Alternatively, you can use the iterator's nth method:
let ch = text.chars().nth(0).unwrap();