fix: avoid mutating self in TagShare::add (#748)

This commit is contained in:
dan
2025-03-27 13:46:27 +01:00
committed by GitHub
parent 8c889ac498
commit 9253adaaa4
2 changed files with 7 additions and 4 deletions

View File

@@ -287,9 +287,12 @@ struct TagShare([u8; 16]);
impl Add for TagShare {
type Output = Vec<u8>;
fn add(mut self, rhs: Self) -> Self::Output {
self.0.iter_mut().zip(rhs.0).for_each(|(a, b)| *a ^= b);
self.0.to_vec()
fn add(self, rhs: Self) -> Self::Output {
self.0
.iter()
.zip(rhs.0)
.map(|(a, b)| *a ^ b)
.collect::<Vec<_>>()
}
}

View File

@@ -95,7 +95,7 @@ impl Task for ComputeTags {
let tags = tag_shares
.into_iter()
.zip(follower_tag_shares)
.map(|(a, b)| (a + b).to_vec())
.map(|(a, b)| a + b)
.collect();
Some(tags)