Closed mina86 closed 1 year ago
By the way, ReadBuf
calls those new
and uninit
. As much as I hate ReadBuf
, maybe it’s worth unifying naming with it?
Ah, that could make sense.
Hmm, then again, BorrowedBuf
doesn’t have constructors at all and uses From
trait. So maybe dropping those constructors would be even better? I have no preference here; wondering what would be best convention.
No, I think it is good practice to have constructors.
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory.
In addition, add
From<&mut [T]>
implementations (forT=u8
andT=MaybeUninit<u8>
) which do conversion from slice to UninitSlice.Fixes: https://github.com/tokio-rs/bytes/issues/552