rust/src/test/ui/suggestions/missing-trait-bound-for-op.fixed

14 lines
365 B
Rust
Raw Normal View History

// run-rustfix
pub fn strip_prefix<'a, T: std::cmp::PartialEq>(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() {}