The English alphabet as a vector of characters in Rust

后端 未结 2 1482
野趣味
野趣味 2021-01-13 07:03

The title says it all. I want to generate the alphabet as a vector of characters. I did consider simply creating a range of 97-122 and converting it to characters, but I was

2条回答
  •  Happy的楠姐
    2021-01-13 07:47

    Collecting the characters of a str doesn't seem like a bad idea...

    let alphabet: Vec = "abcdefghijklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ".chars().collect();
    

提交回复
热议问题