Make Fill_via_u*_chunks not modify src#242
Conversation
dhardy
left a comment
There was a problem hiding this comment.
Looks mostly good, though it's not the first time I've been unimpressed by byteorder code.
src/impls.rs
Outdated
| unsafe { | ||
| // N.B. https://github.com/rust-lang/rust/issues/22776 | ||
| let bytes = transmute::<_, [u8; $size]>(n.to_le()); | ||
| copy_nonoverlapping((&bytes).as_ptr(), |
There was a problem hiding this comment.
bytes is an array, so bytes.as_ptr() should be the same? I'd prefer the following, though unfortunately it means passing another parameter (or get size from size_of):
let tmp = n.to_le();
let src_ptr = &tmp as *const $ty as *const [u8; $size]; // inline this is you like
I don't think you need to reference that bug; I think Rust's lifetime analysis is good enough now to prevent it.
|
Thank you, your alternative looks better 😄. |
|
Glad it worked out. Now we have 4 PRs ready except for CI; hmm... |
|
Yes... All these changes are platform-independent. If the CI passes on Linux, would it be ok to merge? |
|
It's big-endian tests that are really missed. Maybe we do need to port your Travis tweaks to this branch. |
|
I also missed them for the ChaCha PR... Maybe it is best to use just one big-endian platform from it. |
Make `Fill_via_u*_chunks` not modify `src`
I now have 4 branches with
BlockRngCoretrait experiments, but it is hard to get them in a reviewable state. It is mostly the addition of aBlockRngwrapper and just a lot of code moving around.One functional change is the one in this PR. Because it touches somewhat difficult code using unsafe it seemed best to split it out.
Another thing I can split out are changes to the documentation of ChaCha.