Is there a safe way to do the following without losing performance? All the safe variants required me to allocate/copy and return a String.
fn convert_seconds_to_hhmmssmmm(
time_buffer: &mut [u8; 12],
seconds: f64,
millisecond_separator: u8,
) -> &str {
let seconds_truncated = seconds as u64;
let milliseconds = (seconds.fract() * 1000.0) as u64;
let hours = seconds_truncated / 3600;
let minutes = (seconds_truncated / 60) % 60;
let seconds_remaining = seconds_truncated % 60;
time_buffer[2] = b':';
time_buffer[5] = b':';
time_buffer[8] = millisecond_separator;
time_buffer[0] += (hours / 10) as u8;
time_buffer[1] += (hours % 10) as u8;
time_buffer[3] += (minutes / 10) as u8;
time_buffer[4] += (minutes % 10) as u8;
time_buffer[6] += (seconds_remaining / 10) as u8;
time_buffer[7] += (seconds_remaining % 10) as u8;
time_buffer[9] += (milliseconds / 100) as u8;
time_buffer[10] += ((milliseconds / 10) % 10) as u8;
time_buffer[11] += (milliseconds % 10) as u8;
unsafe { std::str::from_utf8_unchecked(time_buffer) }
}
```