Skip to content

Instantly share code, notes, and snippets.

@mbrubeck
Created July 16, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrubeck/bcfed4c1886784e886d9e02c04ebf3bf to your computer and use it in GitHub Desktop.
Save mbrubeck/bcfed4c1886784e886d9e02c04ebf3bf to your computer and use it in GitHub Desktop.
use itertools::zip;
use std::ops::{BitXor, BitXorAssign};
pub fn xor<T>(x: &[T], y: &[T]) -> Vec<T>
where T: BitXor<Output=T> + Copy {
zip(x, y).map(|(a, b)| *a ^ *b).collect()
}
pub fn xor_with<T>(x: &mut [T], y: &[T])
where T: BitXorAssign + Copy {
for (a, b) in zip(x, y) {
*a ^= *b;
}
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment