如何通过传递另一个较小的切片来修改较大切片(或 Vec)的一部分?
How can I modify a part of bigger slice (or Vec) by passing another smaller slice?
如何正确执行下面这段代码?
let mut bigger: [u8; 100] = [0u8; 100];
let smaller: [u8; 3] = [1, 2, 3];
// do something like:
// bigger[0..3] = smaller;
bigger[0..3].copy_from_slice(&smaller);
如何正确执行下面这段代码?
let mut bigger: [u8; 100] = [0u8; 100];
let smaller: [u8; 3] = [1, 2, 3];
// do something like:
// bigger[0..3] = smaller;
bigger[0..3].copy_from_slice(&smaller);