Cast void pointer to trait object

These casts work:

*mut c_void as *mut T // for concrete T
*mut T as *mut c_void // for concrete T
*mut Trait as *mut c_void // for trait Trait

But this doesn't:

*mut c_void as *mut Trait // for trait Trait

It's still sound to make this cast using mem::transmute, right?

Yeah no definitely no I forgot that trait objects are fat pointers. :open_mouth:

2 Likes