Chaining iterators, no copy.

This commit is contained in:
Frederic Jacobs
2016-11-24 16:44:50 +01:00
parent 4e62f3798b
commit 35049f97f2

View File

@ -75,9 +75,7 @@ impl<T: Digest + Clone> PublicKey<T> {
} }
pub fn to_bytes(&self) -> Vec<u8> { pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes = self.zero_values.clone(); self.zero_values.iter().chain(self.one_values.iter()).fold(Vec::new(), |mut acc, i| {
bytes.extend(self.one_values.clone());
bytes.iter().fold(Vec::new(), |mut acc, i| {
acc.append(&mut i.clone()); acc.append(&mut i.clone());
acc acc
}) })