mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
14 lines
344 B
Rust
14 lines
344 B
Rust
|
// run-rustfix
|
||
|
|
||
|
pub fn strip_prefix<'a, T>(s: &'a [T], prefix: &[T]) -> Option<&'a [T]> {
|
||
|
let n = prefix.len();
|
||
|
if n <= s.len() {
|
||
|
let (head, tail) = s.split_at(n);
|
||
|
if head == prefix { //~ ERROR binary operation `==` cannot be applied to type `&[T]`
|
||
|
return Some(tail);
|
||
|
}
|
||
|
}
|
||
|
None
|
||
|
}
|
||
|
fn main() {}
|