2 ms·
Ironically, Rust does allow you to implicitly copy an array as long as it reduces to a memcpy
by brundolf 4y ago
Ironically, Rust does allow you to implicitly copy an array as long as it reduces to a memcpy
- tialaramex 4y agoSpecifically arrays [T; N] are Copy if precisely T is Copy. So, an array of 32-bit unsigned integers [u32; N] can be copied, and so can an array of immutable string references like ["Hacker", "News", "Web", "Site"] but an array of mutable Strings cannot. The array of mutable Strings can be memcpy'd and there are situations where that's actually what Rust will do, but because Strings aren't Copy, Rust won't let you keep both - if it did this would introduce mutable aliasing and so ruin the language's safety promise.