Closed
Description
&str has find_str(). It would be handy to have such a method for slices as well. This is for example useful for work with non-utf8 based strings.
A simple implementation for std::slice::ImmutableEqVector
could be:
/// Returns the index of the first matching subslice
fn find_slice<T: PartialEq>(&self, needle: &[T]) -> Option<uint> {
for i in range(0, this.len()) {
if this.slice_from(i).starts_with(needle) {
return Some(i)
}
}
None
}
If desired I could file a pull request.
Metadata
Metadata
Assignees
Labels
No labels