bytes
bytes copied to clipboard
Improve Buf / BufMut docs
It is not clear how these traits should be implemented when the byte storage is not in continuous memory.
Yeah, we just run into an issue. For our datastructure that's not in continuous memory we implemented Buf
trait. Each of the continuous pieces of this datastructure can be empty, and so Buf::bytes()
might be empty. But if it happens that get_u8()
is called when Buf::bytes()
returns an empty slice then it panics i.e. get_u8()
doesn't check if a slice is empty or not
Do you have thoughts on how to improve the docs? I would :heart: a PR.
Well, I have thoughts on the issue I encountered. In that particular case it's either a documentation issue because docs do not highlight that bytes()
should not return an empty slice, or a problem in the code because get_*8
do not check if bytes()
are empty. I'm happy to send a PR. IMHO, the latter solution is better.
For the BufMut @jsgf might have opinions on that.