As you know, a common one T
can be anything¹, therefore Foo
impls overlaps (conflicts) whenever T
in the first implementation &'a mut U
, because the second impl also covers this case (when T
U
).
Clone
, &mut
Clone
, T where T: Clone
&'a mut T
.² Bar
(&
), , Clone
.
[H] ow ?
"" , , , Rust , struct
, enum
s: ( Rust).
, , , , , " ", , , :
impl Foo for u32 { ... }
impl Foo for i32 { ... }
impl<'a, T> Foo for &'a T where T: Foo + 'a { ... }
impl<'a, T> Foo for &'a mut T where T: Foo + 'a { ... }
¹ , , Sized
, . ?Sized
, , .
² where T: Clone + 'static
, &'a mut T
Clone
, T
.