Conversation
|
Does making the impls here heterogeneous (i.e. |
|
Unsure why I'm assigned, I'm not on the libs team. r? @Mark-Simulacrum |
I don't understand the question. impl<T> [T] {
fn strip_prefix<U>(&self, prefix: &[U]);
} |
|
Also, the Does pub fn starts_with(&self, needle: &[T]) -> bool |
|
r? @SimonSapin |
|
r? @dtolnay |
dtolnay
left a comment
There was a problem hiding this comment.
Thanks! I am on board with this. It matches the method names on str and it matches the starts/ends_with signatures on slice.
|
@bors r+ |
|
📌 Commit 560a996 has been approved by |
Implement `slice_strip` feature Tracking issue: rust-lang#73413
Implement `slice_strip` feature Tracking issue: rust-lang#73413
Implement `slice_strip` feature Tracking issue: rust-lang#73413
Details@bors r- |
src/libcore/slice/mod.rs
Outdated
| /// | ||
| /// ``` | ||
| /// #![feature(slice_strip)] | ||
| /// let v = &[10, 40, 30]; | ||
| /// assert_eq!(v.strip_prefix(&[]), Some(v)); | ||
| /// let v: &[u8] = &[]; | ||
| /// assert_eq!(v.strip_prefix(&[]), Some(v)); | ||
| /// ``` |
There was a problem hiding this comment.
Is this example needed?
83f5819 to
6068504
Compare
src/libcore/slice/mod.rs
Outdated
There was a problem hiding this comment.
I think the wording of this was clearer in a previous revision. Slice not starting with prefix is a scenario that is important to specify; this says what the meaning of Option in the return type is. Empty prefix is a small clarification (not even an edge case, since the behavior falls out from the rest of the documentation). I think the emphasis in this paragraph is backward and not conducive to recognizing the part that is more important.
There was a problem hiding this comment.
I repharsed it. Could you take a look?
|
@bors r+ |
|
📌 Commit cd9d833 has been approved by |
…arth Rollup of 10 pull requests Successful merges: - rust-lang#73414 (Implement `slice_strip` feature) - rust-lang#73564 (linker: Create GNU_EH_FRAME header by default when producing ELFs) - rust-lang#73622 (Deny unsafe ops in unsafe fns in libcore) - rust-lang#73684 (add spans to injected coverage counters, extract with CoverageData query) - rust-lang#73812 (ast_pretty: Pass some token streams and trees by reference) - rust-lang#73853 (Add newline to rustc MultiSpan docs) - rust-lang#73883 (Compile rustdoc less often.) - rust-lang#73885 (Fix wasm32 being broken due to a NodeJS version bump) - rust-lang#73903 (Changes required for rustc/cargo to build for iOS targets) - rust-lang#73938 (Optimise fast path of checked_ops with `unlikely`) Failed merges: r? @ghost
Tracking issue: #73413