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 initialize an array of Option<Foo> with [None; 5]. The None variant is constant and has no associated data, so there seems to be no reason that it couldn't be copied into all the entries in the array:
Sadly this errors because Foo is not Copy, so Option<Foo> is not Copy.
<anon>:4:35: 4:44 error: the trait `core::marker::Copy` is not implemented for the type `Foo` [E0277]
<anon>:4 let array: [Option<Foo>; 5] = [None; 5];
^~~~~~~~~
I gather array initialization treats None as an expression in this case? Could it instead notice that None is a constant, and copy it to all the elements in the array?