diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-07-29 09:24:17 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-29 09:24:17 +0900 |
| commit | 6968b75bd0524915d3fcf6b201b41827d4695603 (patch) | |
| tree | 28c242417d38f01677cb0d1a66e616d71cb2fdaf /src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs | |
| parent | 157975c6c40b02e56e931617f1d6c8148bc7d2bd (diff) | |
| parent | 6e9dc7d9ff806eb3a0b99ffd10892dac8e6f9739 (diff) | |
| download | rust-6968b75bd0524915d3fcf6b201b41827d4695603.tar.gz rust-6968b75bd0524915d3fcf6b201b41827d4695603.zip | |
Rollup merge of #74707 - matklad:split_once, r=dtolnay
Add str::[r]split_once
This is useful for quick&dirty parsing of key: value config pairs. Used a bunch in Cargo and rust-analyzer:
* https://github.com/rust-lang/cargo/search?q=splitn%282&unscoped_q=splitn%282
* https://github.com/rust-analyzer/rust-analyzer/search?q=split_delim&unscoped_q=split_delim
In theory, once const-generics are done, this functionality could be achieved without a dedicated method with
```rust
match s.splitn(delimier, 2).collect_array::<2>() {
Some([prefix, suffix]) => todo!(),
None => todo!(),
}
```
Even in that world, having a dedicated method seems clearer on the intention.
I am not sure about naming -- this is something I've just came up with yesterday, I don't know off the top of my head analogs in other languages.
If T-libs thinks this is a reasonable API to have, I'll open a tracking issue and add more thorough tests.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs')
0 files changed, 0 insertions, 0 deletions
