You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently made num-bytes for this purpose, I think its a fairly common usage so I just thought it worth suggesting as something that maybe should be added.
Used like:
let a = [8,0];let b:i16 = from_generic(a);assert_eq!(b,8);fnfrom_generic<T: num_bytes::FromBytes<N>,constN:usize>(x:[u8;N]) -> T{T::from_le_bytes(x)}
and:
let a = 8i16;let b = into_generic(a);assert_eq!(b,[8,0]);fninto_generic<T: num_bytes::IntoBytes<N>,constN:usize>(x:T) -> [u8;N]{
x.into_le_bytes()}
Since rust-lang/rust#76560 remains incomplete and unstable, this is the reason the current implementation of the trait is a little awkward.
The future simpler implementation could look like:
I recently made num-bytes for this purpose, I think its a fairly common usage so I just thought it worth suggesting as something that maybe should be added.
Used like:
and:
Since rust-lang/rust#76560 remains incomplete and unstable, this is the reason the current implementation of the trait is a little awkward.
The future simpler implementation could look like:
The text was updated successfully, but these errors were encountered: