about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/optimize/code_layout.rs
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-12-10 21:33:08 -0800
committerGitHub <noreply@github.com>2020-12-10 21:33:08 -0800
commit17ec4b8258b3f59ded7b2cfae8484be976c658af (patch)
tree78e69a92950080416cb1097e7b28c1b76a692ca4 /compiler/rustc_codegen_cranelift/src/optimize/code_layout.rs
parent8b9a59cb905f2f22c7de7713e38756b20289e0b9 (diff)
parent989edf4a5ffb0944e173ec23cb5614c252e8082e (diff)
downloadrust-17ec4b8258b3f59ded7b2cfae8484be976c658af.tar.gz
rust-17ec4b8258b3f59ded7b2cfae8484be976c658af.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/optimize/code_layout.rs')
0 files changed, 0 insertions, 0 deletions