Skip to content

Instantly share code, notes, and snippets.

@JosephTLyons
Created January 9, 2022 06:56
Show Gist options
  • Select an option

  • Save JosephTLyons/07fe003bc3a65cb3b58403c3f9e17845 to your computer and use it in GitHub Desktop.

Select an option

Save JosephTLyons/07fe003bc3a65cb3b58403c3f9e17845 to your computer and use it in GitHub Desktop.
How to slice a string via code points in Rust
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