trait DataLen {
fn len(&self) -> usize;
}
impl DataLen for &str {
fn len(&self) -> usize {
let mut len = self.len();
for pair in self.as_bytes().windows(2) {
len -= 2;
match pair {
(r#"\\"#).as_bytes() | (r#"\""#).as_bytes() => len -= 2,
(r#"\x"#).as_bytes() => len -= 4,
_ => {}
}
}
len
}
}
Compiler says that it expected one of =>, if, or |. But as you can probably notice I am trying to match pair against (r#"\\"#).as_bytes()