`impl Trait`s require import the trait while `dyn Trait`s doesn't
The Rust Programming Language Forum
`impl Trait`s require import the trait while `dyn Trait`s doesn't
So, say we have an impl std::io::Write, we have to import use std::io::Write; Before writeln! to it. However, if we have a dyn std::io::Write, writeln! will work without std::io::Write in the scope. I guess this is because impl Trait is some syntax suger that resolves to adding an anonymous type parameter. But is there any space of improvement for the compiler? What will be the problems / difficulties if we want impl Traits to work as dyn Traits?
0 comments
No comments yet.