Created
January 9, 2022 06:56
-
-
Save JosephTLyons/07fe003bc3a65cb3b58403c3f9e17845 to your computer and use it in GitHub Desktop.
How to slice a string via code points in Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let text = "Super🐍Snake"; | |
| let text_slice = &text.chars().collect::<Vec<_>>()[5..=10]; | |
| for character in text_slice { | |
| println!("{}", character); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment