std-method
str::split_once
Separate text at the first delimiter and keep the remaining delimiters in the suffix. A missing delimiter returns None. Expected stdout (not executed): url -> a:b Common mistake: Assuming every delimiter is removed from the suffix.
Formal Syntax & Structure
rust syntaxrust
fn split_once<P: Pattern>(&self, delimiter: P) -> Option<(&str, &str)>Working Example
Example Snippetrust
fn main() { let (key, value) = "url:a:b".split_once(':').unwrap(); println!("{key} -> {value}");}