| 113 | } |
| 114 | |
| 115 | pub fn insert_slice_strided(input: &mut Vec<u8>, x: &[u8], offset: usize, stride: usize) { |
| 116 | let len = x.len() * stride; |
| 117 | |
| 118 | let position = offset..((offset + len).min(input.len())); |
| 119 | input.resize(input.len() + len, 0); |
| 120 | input.copy_within(position, offset + len); |
| 121 | |
| 122 | for (chunk, byte) in input[offset..offset + len].chunks_exact_mut(stride).zip(x) { |
| 123 | chunk.fill(*byte); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | pub fn replace_slice_strided(input: &mut Vec<u8>, x: &[u8], offset: usize, stride: usize) { |
| 128 | let len = x.len() * stride; |