yinser
Joined 4 years ago
Karma
550
Submissions
159
Member since
Aug 10
Joined 4 years ago
https://www.nasa.gov/general/lunar-crater-radio-telescope-lc...
// Use a mutable slice to represent the buffer:
let mut buffer = [0u8; 16];
// Read into the buffer:
let n = socket.read(&mut buffer)?;
// To move the partial second row to the beginning, you'd use safe operations like:
let second_row_start = 7; // Index where second row starts
buffer.copy_within(second_row_start.., 0);
// Then read more data into the remaining space:
let remaining_space = &mut buffer[9..];
let additional_bytes = socket.read(remaining_space)?;
Is this idiomatic for Rust?