bytes icon indicating copy to clipboard operation
bytes copied to clipboard

Consider adding `BytesRef`

Open carllerche opened this issue 4 years ago • 3 comments

This would be the Bytes equivalent of WakerRef.

If we do that, then we could switch Bytes::slice_ref -> BytesRef::new(&my_bytes, my_slice)... possibly even adding BytesRef::new_unchecked.

Follow up to #298.

carllerche avatar Oct 15 '19 18:10 carllerche

What does this add over let slice = &bytes[a..b]?

seanmonstar avatar Oct 15 '19 19:10 seanmonstar

It lets you slice further into owned handles.

carllerche avatar Oct 15 '19 19:10 carllerche

When you clone a WakerRef you get a Waker. Which in Wakers cases typically is just a refcount bump, since the Waker has already been allocated.

What would cloneing a BytesRef do? If it gives us Bytes, then the clone in the vtable needs to be implemented as a heap allocation. If it gives us another BytesRef (in order to just slice the ref), then the required vtable function is different.

Matthias247 avatar Dec 09 '19 05:12 Matthias247