Created
July 16, 2018 17:56
-
-
Save mbrubeck/bcfed4c1886784e886d9e02c04ebf3bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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