bytes icon indicating copy to clipboard operation
bytes copied to clipboard

Is the conversion from bytes to Vec<u8> O(1)

Open cBournhonesque opened this issue 2 months ago • 5 comments

Is the conversion from bytes to Vec O(1) if the underlying memory is already contiguous and the ref count is 1?

Or do we still have new allocations and copying?

I looked at https://github.com/tokio-rs/bytes/pull/547, it seems to suggest that it indeed is O(1) but the docs say

Copies self into a new Vec.

cBournhonesque avatar Jun 04 '24 14:06 cBournhonesque