darley
1
Hi folks, how can I make the following code as simple as possible (removing the intermediate variables):
// I want to get rid of this n
let n: [u8;4] = buffer[4..8].try_into()?;
let res = u32::from_ne_bytes(n); // I want to use res
Thanks in advance!
chrefr
2
It works beautifully on one line (playground):
let res = u32::from_ne_bytes(buffer[4..8].try_into()?);
4 Likes
system
Closed
5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.