Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Method cannot be invoked on a trait object until its supertrait is brought into scoope
I was trying to call bytes
on a BufRead
trait object and initially received the error that the method couldn't be invoked because bytes
has Sized
requirement. However, if std::io::Read
is brought into scope, the call to bytes
goes through. I understand that bytes
is a method of the Read
trait, so having the use
statement for it makes sense, but I'm having a bit of trouble understanding how adding the import seems to suddenly make a trait object Sized
.
I did a bit of research and my intuition is that perhaps the compiler doesn't create the concrete method to dispatch to without the import of Read
, but I don't have the knowledge to say for certain if that's the case or not. Could anyone give me some more insight as to what's happening here? Thanks!
2 posts - 2 participants
🏷️ rust_feed