2020-09-23 08:44:11 +00:00
|
|
|
use std::convert::TryInto;
|
|
|
|
|
|
|
|
fn take_array_from_mut<T, const N: usize>(data: &mut [T], start: usize) -> &mut [T; N] {
|
2024-06-17 08:34:26 +00:00
|
|
|
(&mut data[start..start + N]).try_into().unwrap()
|
2020-09-23 08:44:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut arr = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
|
|
|
2024-06-17 08:34:26 +00:00
|
|
|
for i in 1..4 {
|
2020-09-23 08:44:11 +00:00
|
|
|
println!("{:?}", take_array_from_mut(&mut arr, i));
|
|
|
|
//~^ ERROR type annotations needed
|
2024-06-17 08:34:26 +00:00
|
|
|
//~| ERROR type annotations needed
|
2020-09-23 08:44:11 +00:00
|
|
|
}
|
|
|
|
}
|