std-method
str::split
Iterate over borrowed pieces between matches. Consecutive delimiters can yield empty pieces; this is not a general CSV parser. Expected stdout (not executed): ["a", "", "c"] Common mistake: Assuming empty fields disappear automatically.
Formal Syntax & Structure
rust syntaxrust
fn split<P: Pattern>(&self, pat: P) -> Split<'_, P>Working Example
Example Snippetrust
fn main() { let fields: Vec<&str> = "a,,c".split(',').collect(); println!("{fields:?}");}