.split_once(..)
RS-W1066splitn(2, ..)
is more written more concisely with split_once
.
The key difference between the two methods are their return types:
"a string".splitn(2, ..)
returns an Iterator<Item = &str>
"a string".split_once(..)
returns an Option<(&str, &str)>
let mut x = "test=value=items".splitn(2, '=');
if let (Some(x1), Some(x2)) = (x.next(), x.next()) {
// ..
}
if let Some((x1, x2)) = "test=value=items".split_once('=') {
// ..
}