-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add <[T; N]>::copied #76236
Add <[T; N]>::copied #76236
Conversation
I really want that method (and |
for i in 0..N { | ||
dst[i].write(self[i].copy()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, do we get "guaranteed" bounds check elimination here? That is, am I correct that rewriting this as dst.iter_mut().zip(self.iter())
would make this strictly worse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After mir-opt the check is against a constant, which is quite easy for LLVM to remove. (The for i in 0..N
loop is easily canonicalized, especially now that Range<usize>::next
uses add nuw
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must we write byte by byte if it implements Oh, I forgot it is a reference not original value.copy
?
I believe the next thing we will be adding is |
Given #76236 (comment) I'll just close this. |
This works (it's a nicer version of how I did things in
ArrayTools
), so I figured I'd just send a PR and see what people think about it.r? @LukasKalbertodt
cc #76118