3 ms·
Minor point: `let padding = &mut bytes[..index]; padding[index]` is an out-of-bounds index and will panic even if the borrow checker accepted it. You probably w
by Arnavion 3y ago
Minor point: `let padding = &mut bytes[..index]; padding[index]` is an out-of-bounds index and will panic even if the borrow checker accepted it. You probably wanted `let padding = &mut bytes[..=index];`
- diarrhea 3y agoThank you. For some reason, I’ve always had immense trouble with index bound arithmetic (questions like: is this inclusive? Exclusive? Is ..0 a single element or none? What about ..=0?). I have to actively think about these as I do when telling East from West. North versus South is simply intuitive, no conscious thought needed. Weird effect. Glad to see I wasn’t wrong in stumbling over this particular one.