-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add str::[r]split_once #74707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add str::[r]split_once #74707
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
d520bab
to
4a7b4df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks plausible to me. Could you make a tracking issue please?
91b38b0
to
bb2687d
Compare
tests&tracking issue added! |
@bors r+ |
📌 Commit bb2687d has been approved by |
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.
⌛ Testing commit bb2687d with merge d1b9d490b3374c4af4239be2875a7ca4f3a02b67... |
💔 Test failed - checks-actions |
☔ The latest upstream changes (presumably #73265) made this pull request unmergeable. Please resolve the merge conflicts. |
This is useful for quick&dirty parsing of key: value config pairs
Rebased! Given that the failure seems completely unrelated, I am going to @bors r=dtolnay |
📌 Commit 6e9dc7d has been approved by |
⌛ Testing commit 6e9dc7d with merge 1c984308eca9a30ec54bed3d3edcbb179a7788ab... |
💔 Test failed - checks-actions |
A different spurious error:
@bors retry |
⌛ Testing commit 6e9dc7d with merge 8725668584b02dce2fd223aed0dd53c1eedc4a57... |
💔 Test failed - checks-azure |
Hm, the same spurious network error:
I guess crates.io is not feeling great today? |
Ok, lets try this again @bors retry |
Rollup of 8 pull requests Successful merges: - rust-lang#74266 (Clean up E0720 explanation) - rust-lang#74671 (add const generics array coercion test) - rust-lang#74707 (Add str::[r]split_once) - rust-lang#74814 (Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy) - rust-lang#74859 (Update outdated readme) - rust-lang#74864 (ayu theme: Change doccomment color to `#a1ac88`) - rust-lang#74872 (Enable to ping RISC-V group via triagebot) - rust-lang#74891 (handle ConstEquate in rustdoc) Failed merges: r? @ghost
This is useful for quick&dirty parsing of key: value config pairs. Used a bunch in Cargo and rust-analyzer:
In theory, once const-generics are done, this functionality could be achieved without a dedicated method with
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.