3 ms·
A slice of a non-ZST element cannot have `usize::MAX` elements, by definition of `usize`.
by GlitchMr 8y ago
A slice of a non-ZST element cannot have `usize::MAX` elements, by definition of `usize`.
- eridius 8y agoSlices of ZST elements is indeed what I was thinking of, but is there anything actually stopping me from constructing a `std::slice::from_raw_parts(0 as *const u8, usize::MAX)`? What if I'm working on an architecture where the heap and stack are separate address spaces, and every single address in the heap is reachable? In fact, doesn't WebAssembly work this way? If I can declare that my linear memory is usize::MAX bytes, then constructing a slice that covers the entire memory address seems like a potentially-valid thing to do.