rust/library/std/src/sys_common
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
..
bytestring std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
condvar Make it possible to have unboxed mutexes on specific platforms. 2020-10-02 09:47:08 +02:00
net std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
remutex Use Pin for the 'don't move' requirement of ReentrantMutex. 2020-12-08 22:57:57 +01:00
thread_local_key std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
thread_parker Use futex-based thread-parker for Wasm32. 2020-10-06 20:02:02 +02:00
wtf8 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
alloc.rs library/std/sys_common: Define MIN_ALIGN for sparc-unknown-linux-gnu 2020-09-28 00:39:57 +02:00
at_exit_imp.rs Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00
backtrace.rs For backtrace, use StaticMutex instead of a raw sys Mutex. 2020-10-07 13:59:03 +02:00
bytestring.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
condvar.rs Make it possible to have unboxed condvars on specific platforms. 2020-10-02 09:47:08 +02:00
fs.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
io.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
mod.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00
mutex.rs Remove lifetime from StaticMutex and assume 'static. 2020-10-14 09:52:03 +02:00
net.rs Fix net.rs - rsplitn() returns a reverse iterator 2020-12-07 18:47:10 -07:00
os_str_bytes.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
poison.rs Move to Arc::clone(&x) over x.clone() in library/std 2020-08-30 21:59:43 +02:00
process.rs Add accessors to Command. 2020-09-26 18:58:38 -07:00
remutex.rs Use Pin for the 'don't move' requirement of ReentrantMutex. 2020-12-08 22:57:57 +01:00
rwlock.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
tests.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
thread.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_info.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_local_dtor.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
thread_local_key.rs Split sys_common::Mutex in StaticMutex and MovableMutex. 2020-09-27 10:05:56 +02:00
util.rs mv std libs to library/ 2020-07-27 19:51:13 -05:00
wtf8.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00