Update big int from_be_bytes with iterators
Co-authored-by: Sebastian <geisler.sebastian@googlemail.com>
This commit is contained in:
parent
2fd353d5ab
commit
42bf893d8b
|
@ -92,9 +92,10 @@ macro_rules! construct_uint {
|
||||||
pub fn from_be_bytes(bytes: [u8; $n_words * 8]) -> $name {
|
pub fn from_be_bytes(bytes: [u8; $n_words * 8]) -> $name {
|
||||||
use super::endian::slice_to_u64_be;
|
use super::endian::slice_to_u64_be;
|
||||||
let mut slice = [0u64; $n_words];
|
let mut slice = [0u64; $n_words];
|
||||||
for n in 0..$n_words {
|
slice.iter_mut()
|
||||||
slice[$n_words - n - 1] = slice_to_u64_be(&bytes[(n * 8)..(n * 8 + 8)]);
|
.rev()
|
||||||
}
|
.zip(bytes.chunks(8))
|
||||||
|
.for_each(|(word, bytes)| *word = slice_to_u64_be(bytes));
|
||||||
$name(slice)
|
$name(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue