The following code:
use std::borrow::Cow;
struct Hip<'a> {
hip: Cow<'a, [u8]>
}
struct Hop<'a, T: ?Sized + 'a> {
hop: Cow<'a, T>
}
fn main() {
let it_be: Hop<[u8]> = [1, 2, 3];
}
Fails to build because "the trait Clone is not implemented for T".
Whereas expecting T to implement Clone (as follows):
struct Hop<'a, T: Clone + ?Sized + 'a> {
hop: Cow<'a, T>
}
Fails to build because "the trait Clone is not implemented for [u8]".
How come Hip, which is using a [u8], compiles, but not Hop?
Why does the compiler request Clone to be implemented for Hop's T, but not for Hip's [u8]?