Add array! macro for non-copy types#33
Conversation
|
This is unsound. Consider what happens if |
| for i in 0..$count { | ||
| res[i] = ::std::mem::MaybeUninit::new($value); | ||
| } |
There was a problem hiding this comment.
| for i in 0..$count { | |
| res[i] = ::std::mem::MaybeUninit::new($value); | |
| } | |
| for elem in &mut res[..] { | |
| elem.write($value); | |
| } |
A little cleaner, taken from https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#initializing-an-array-element-by-element
There is no The only issue would be a potential |
Well, the user could provide |
|
Oh I see what you mean now. Maybe moving the expression to a variable outside the loop and cloning it for every element would be better in that regard? |
Fixes: #32