Can i implement trait for other library type?



Is it possible to implement my own trait for some third party library?


Yes. The only trick is that the trait must be in scope (use Trait) when you use it.


awesome. So, I can, for example, implement my own trait, for TcpStream in Tokio . right ?


Yes. You can implement your own trait for not-your type, or you can implement not-your trait for your type. As long as one of the sides is defined in your crate, it’s fine.