rust/library/std/src
Tyler Mandry 17ec4b8258
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.
2020-12-10 21:33:08 -08:00
..
backtrace Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
collections Rollup merge of #77996 - tkaitchuck:master, r=m-ou-se 2020-11-13 15:26:10 +01:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
ffi Bump bootstrap compiler version 2020-11-19 19:23:36 -05:00
fs std: Fix test got_symlink_permission on Windows 2020-11-16 21:09:26 +03:00
io Auto merge of #77801 - fusion-engineering-forks:pin-mutex, r=Mark-Simulacrum 2020-12-10 23:43:20 +00:00
lazy std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
memchr std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
net Move const ip in ui test to unit test 2020-11-26 23:15:32 +09:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
prelude Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
process std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
sync Convert a bunch of intra-doc links 2020-11-07 12:50:57 -08:00
sys Rollup merge of #79375 - vext01:kernel-copy-temps, r=bjorn3 2020-12-10 21:33:02 -08:00
sys_common Rollup merge of #79809 - Eric-Arellano:split-once, r=matklad 2020-12-10 21:33:08 -08:00
thread Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
time Duration::zero() -> Duration::ZERO 2020-10-21 20:44:03 -07:00
alloc.rs Rename AllocRef to Allocator and (de)alloc to (de)allocate 2020-12-04 14:47:15 +01:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs Add column number support to Backtrace 2020-11-15 13:09:56 +01:00
env.rs Improve docs for std::env::args() 2020-09-04 14:00:09 -07:00
error.rs Rename LayoutErr to LayoutError outside of core 2020-10-08 00:40:10 -04:00
f32.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
f64.rs Rollup merge of #77027 - termhn:mul_add_doc_change, r=m-ou-se 2020-12-10 21:32:59 -08:00
fs.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
future.rs Fix stabilization marker for future_readiness_fns 2020-09-15 23:12:08 +02:00
keyword_docs.rs Rollup merge of #79383 - abdnh:patch-1, r=shepmaster 2020-11-28 15:58:21 +01:00
lazy.rs Add (internal-only) SyncOnceCell::get_or_init_pin. 2020-12-08 22:57:50 +01:00
lib.rs Rollup merge of #79809 - Eric-Arellano:split-once, r=matklad 2020-12-10 21:33:08 -08:00
macros.rs Use ? in core/std macros 2020-10-26 07:15:37 +09:00
memchr.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
num.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
panic.rs Add tracking issue number for panic_any. 2020-10-28 21:23:45 +01:00
panicking.rs Merge set_panic and set_print into set_output_capture. 2020-11-10 21:58:13 +01:00
path.rs Clean up intra-doc links in std::path 2020-10-27 20:54:30 -07:00
primitive_docs.rs Use more std:: instead of core:: in docs for consistency, add more intra doc links 2020-12-02 00:41:53 +01:00
process.rs Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum 2020-11-23 19:01:19 +00:00
rt.rs Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
time.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00