mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
9f3998b4aa
Stabilize split_inclusive ### Contents of this MR This stabilises: * `slice::split_inclusive` * `slice::split_inclusive_mut` * `str::split_inclusive` Closes #72360. ### A possible concern The proliferation of `split_*` methods is not particularly pretty. The existence of `split_inclusive` seems to invite the addition of `rsplit_inclusive`, `splitn_inclusive`, etc. We could instead have a more general API, along these kinds of lines maybe: ``` pub fn split_generic('a,P,H>(&'a self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; pub fn split_generic_mut('a,P,H>(&'a mut self, pat: P, how: H) -> ... where P: Pattern where H: SplitHow; trait SplitHow { fn reverse(&self) -> bool; fn inclusive -> bool; fn limit(&self) -> Option<usize>; } pub struct SplitFwd; ... pub struct SplitRevInclN(pub usize); ``` But maybe that is worse. ### Let us defer that? ### This seems like a can of worms. I think we can defer opening it now; if and when we have something more general, these two methods can become convenience aliases. But I thought I would mention it so the lang API team can consider it and have an opinion. |
||
---|---|---|
.. | ||
alloc | ||
backtrace@af078ecc0b | ||
core | ||
panic_abort | ||
panic_unwind | ||
proc_macro | ||
profiler_builtins | ||
rtstartup | ||
rustc-std-workspace-alloc | ||
rustc-std-workspace-core | ||
rustc-std-workspace-std | ||
std | ||
stdarch@9c732a56f6 | ||
term | ||
test | ||
unwind |