Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Calling methods on a BufRead trait object
I'm working through the Command Line Rust book and just completed the headr
program. The provided open
function returns a file handle as a Box<dyn BufRead>
type. In his solution, the author calls a read
method on this object, which isn't present on BufRead
's interface. My understanding was that, because you only know that you're dealing with something that implements BufRead
, you would only be able to call those methods BufRead
itself provides.
I see in the docs that the Read
trait has the read
method, and is listed as implementing BufRead
, but that doesn't seem like it's the correct relationship for BufRead
to also have read
available.
What am I misunderstanding? Am I reading the docs incorrectly?
3 posts - 2 participants
🏷️ rust_feed