Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
Created February 2, 2023 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barseghyanartur/8535c79b6b60e998ed21d6df876faf9c to your computer and use it in GitHub Desktop.
Save barseghyanartur/8535c79b6b60e998ed21d6df876faf9c to your computer and use it in GitHub Desktop.
Split string by char in Rust

Split string by char in Rust

One way

let original = "What a day!";
let split: Vec<&str> = original.split(" ").collect();
dbg!(&split);

Or another

// ...
let split = original.split(" ").collect::<Vec<&str>>();
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment