2 ms·
Thank you again, I'm not able to determine if any of this is contrived but it's turned into a great teaching opportunity. I am highly impressed with Rust. The c
by yinser 2y ago
Thank you again, I'm not able to determine if any of this is contrived but it's turned into a great teaching opportunity. I am highly impressed with Rust. The compile error looks extremely expressive of the core issue. I'm also new to zig if you can tell but this has helped me position the two languages and their goals better.
- Measter 2y agoI think Steve might have forgotten (so many helper functions...), but Rust's slices have a `copy_within`[1] function for exactly this scenario: fn main() { let mut buf: [u8; 16] = *b"D04GOKUD09OVER90"; buf.copy_within(7..16, 0); println!("{:?}", buf); } It does only support types that are trivially copyable, but it's implemented exactly you'd expect: bounds checking then memcopy handling overlap. [1] https://doc.rust-lang.org/std/primitive.slice.html#method.copy_within https://doc.rust-lang.org/std/primitive.slice.html#method.co...
- steveklabnik 2y agoI did! Wow! Thanks :)