pub trait Decode: Sized {
fn decode(bytes: &[u8]) -> Result<Self>;
}
impl Decode for &str {
fn decode(bytes: &[u8]) -> Result<&str> {
str::from_utf8(bytes).map_err(Error::Utf8)
}
}
Compiler errors:
error: `impl` item signature doesn't match `trait` item signature
error: found `fn(&'1 [u8]) -> std::result::Result<&'1 str, Error>`
note: expected signature `fn(&'1 [u8]) -> std::result::Result<&'2 str, Error>`
found signature `fn(&'1 [u8]) -> std::result::Result<&'1 str, Error>`
error: expected `fn(&'1 [u8]) -> std::result::Result<&'2 str, Error>`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
help: consider borrowing this type parameter in the trait