hi folks! why does an assoc type with a Self: Sized bound non dyn usable? (I just crammed this fact and I don't know why exactly does it work this way....)
trait Trait { type Foo where Self: Sized; fn foo(&self) -> Self::Foo where Self: Sized; fn bar(&self) {} } impl Trait for i32 { type Foo = (); fn foo(&self) -> Self::Foo {} } impl Trait for u64 { type Foo = f32; fn foo(&self) -> Self::Foo { 0.0 } } // No need for `dyn Trait<Foo = ()>`! let mut a: &dyn Trait = &0_i32; // No need for associated type equality between base types! a = &0_u64; // This fails because the type is not defined (`dyn Trait` is not `Sized`) // let _: <dyn Trait as Trait>::Foo = todo!(); 2 posts - 2 participants