tokio-rs / bytes

Utilities for working with bytes
MIT License
1.91k stars 288 forks source link

There is no Bytes::advance #621

Closed Garmelon closed 1 year ago

Garmelon commented 1 year ago

The must_use warning on Bytes::split_to suggests using Bytes::advance if you don't need the returned value. However, that function is private since d8134903de1be93227ce376e1fb640ac2acfa8c1.

It would be nice to be able to write buf.advance(n) instead of let _ = buf.split_to(n).

Walnut356 commented 1 year ago

advance is part of trait Buf, and is implemented on Bytes here. Traits are always public, so as long as use bytes::Buf; is in scope, you should be able to buf.advance(n) as you described.

Garmelon commented 1 year ago

Oh, my bad. Sorry for the issue then. I relied too much on my editor which wasn't able to find Buf because only Bytes was reexported by axum, and when I searched in the cargo doc, I didn't think to ctrl+f advance.