I'm learning Rust by reading codes of Rust applications and I often struggle with finding traits' method implementations for structs.
For instance, I have the following code:
fn peek_u8(src: &mut Cursor<&[u8]>) -> Result<u8, Error> {
if !src.has_remaining() {
return Err(Error::Incomplete);
}
Ok(src.chunk()[0])
}
I want to know where the definition and origin of the 'has_remaining' and 'chunk' method of Cursor. After some Internet research, I found out It originates from 'bytes::Buf' trait. However, I couldn't find that of 'chunk'.
Every time I meet this kind of situations, It is hard to find how struct has methods in it (which trait implements the methods?). Sometime It has very high time costs.
Are there some tips for me?