Support a copying read from Unalign<T>
where T: !Copy
but is FromBytes + IntoBytes
#2004
Labels
customer-request
Documents customer requests.
When working with generic code where we don't want to require
Copy
for large structs but is still constructed from unaligned bytes, theRef::read
method comes in handy. However, this doesn't work when you have aRef<&[u8], [Unalign<T>]>
, since there's no builtin way to index aRef<_, [T]>
.It'd be very nice if I could take some
&Unalign<T>
and copy out aT
whereT: FromBytes + IntoBytes
. This would be infallible shorthand forT::read_from_bytes(unaligned_val.as_bytes()).unwrap()
. I'm not aware of an infallible way to copy out of anUnalign<T> where T: !Copy
.The text was updated successfully, but these errors were encountered: