std-method
BufRead::split: delimited bytes
Produce byte-vector results separated by the selected byte. The delimiter is excluded. Consecutive delimiters can yield empty fields; a final delimiter does not create an additional trailing field. Expected stdout (not executed): "a" "" "b" Common mistake: Treating split as a full CSV parser or assuming a trailing empty record.
Formal Syntax & Structure
rust syntaxrust
reader.split(delimiter: u8) -> Split<Self>Working Example
Example Snippetrust
fn main() { use std::io::BufRead; let r = &b"a||b|"[..]; for field in r.split(b'|') { println!("{:?}", String::from_utf8(field.unwrap()).unwrap()); }}