Rollup merge of #79809 - Eric-Arellano:split-once, r=matklad
Dogfood `str_split_once()` Part of https://github.com/rust-lang/rust/issues/74773. Beyond increased clarity, this fixes some instances of a common confusion with how `splitn(2)` behaves: the first element will always be `Some()`, regardless of the delimiter, and even if the value is empty. Given this code: ```rust fn main() { let val = "..."; let mut iter = val.splitn(2, '='); println!("Input: {:?}, first: {:?}, second: {:?}", val, iter.next(), iter.next()); } ``` We get: ``` Input: "no_delimiter", first: Some("no_delimiter"), second: None Input: "k=v", first: Some("k"), second: Some("v") Input: "=", first: Some(""), second: Some("") ``` Using `str_split_once()` makes more clear what happens when the delimiter is not found.
This commit is contained in:
commit
17ec4b8258
22 changed files with 197 additions and 191 deletions
|
@ -314,6 +314,7 @@
|
|||
#![feature(stdsimd)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(str_split_once)]
|
||||
#![feature(test)]
|
||||
#![feature(thread_local)]
|
||||
#![feature(thread_local_internals)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue