You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to have an array of 65535 elements of Option<NonCopyType> with everything initialized to None, but I couldn't figure out any way to do it.
The obvious approach of [None; 65535] causes the compiler to complain that the element type isn't Copy. Which is true, but obviously the value None itself should be copyable. (Though to be honest, I'm not sure why the bound is Copy and not Clone in the first place).
I also tried using Default::default(), but unfortunately, default is only implemented for arrays up to size 32, so that didn't work either.
I ended up having to create a Vec and manually push(None) in a loop, even though the size is statically known!
The text was updated successfully, but these errors were encountered:
I want to have an array of 65535 elements of
Option<NonCopyType>
with everything initialized to None, but I couldn't figure out any way to do it.The obvious approach of [None; 65535] causes the compiler to complain that the element type isn't Copy. Which is true, but obviously the value None itself should be copyable. (Though to be honest, I'm not sure why the bound is Copy and not Clone in the first place).
I also tried using Default::default(), but unfortunately, default is only implemented for arrays up to size 32, so that didn't work either.
I ended up having to create a Vec and manually push(None) in a loop, even though the size is statically known!
The text was updated successfully, but these errors were encountered: