after reading through this question #1141496871051870289 message I went on a quest to learn more about Unsized, and I have some questions:
What are the drawbacks of removing the Sized trait from a type?
e.g.: struct NewType<T: ?Sized>(T);
Is there any reason why I'd not remove this from every generic type I define?
I can still avoid adding ?Sized on the impl blocks if necessary, but just defining the type like this allows unsized coercions, with no cost at all.
(and why is this not the default behavior? if there is no harm in not adding Sized to every generic, why does the compiler adds it by default?)
Similarly, how does the std decides from what types to remove the Sized trait?
For example, why is Option defined over a generic sized T, while RwLock decides to explicitly removes it?
Before I read about unsized coercion and had a deeper understanding of this, I've expected something like:
let _: &Option<dyn Any> = &Some("test");
to work and I don't really see how it's harmful or any different from:
let _: &RwLock<dyn Any> = &RwLock::new("test");
which does work fine because it removes the default Sized trait