-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Currently there are two lambdas that converts u32 and u64 into an array:
fn from(val: RawNtpPacket) -> Self {
// left it here for a while, maybe in future Rust releases there
// will be a way to use such a generic function with compile-time
// size determination
// const fn to_array<T: Sized>(x: &[u8]) -> [u8; mem::size_of::<T>()] {
// let mut temp_buf = [0u8; mem::size_of::<T>()];
//
// temp_buf.copy_from_slice(x);
// temp_buf
// }
let to_array_u32 = |x: &[u8]| {
let mut temp_buf = [0u8; mem::size_of::<u32>()];
temp_buf.copy_from_slice(x);
temp_buf
};
let to_array_u64 = |x: &[u8]| {
let mut temp_buf = [0u8; mem::size_of::<u64>()];
temp_buf.copy_from_slice(x);
temp_buf
};Describe the solution you'd like
When this rust-lang/rust#43408 would be resolved let's update the implementation with generic size_of::<T>() usage.
Describe alternatives you've considered
N/A
Additional context
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request