From 0051cbd48e34833694e5383af3c5c7470eba7798 Mon Sep 17 00:00:00 2001 From: Benjamin Lipp Date: Wed, 15 Nov 2023 14:22:20 +0100 Subject: [PATCH] doc: Add unit test for xor_into --- rosenpass/src/util.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rosenpass/src/util.rs b/rosenpass/src/util.rs index 281f91de..2f7c231d 100644 --- a/rosenpass/src/util.rs +++ b/rosenpass/src/util.rs @@ -15,6 +15,17 @@ use std::{ use crate::coloring::{Public, Secret}; +/// Xors a and b element-wise and writes the result into a. +/// +/// # Examples +/// +/// ``` +/// use rosenpass::util::xor_into; +/// let mut a = String::from("hello").into_bytes(); +/// let b = b"world"; +/// xor_into(&mut a, b); +/// assert_eq!(&a, b"\x1f\n\x1e\x00\x0b"); +/// ``` #[inline] pub fn xor_into(a: &mut [u8], b: &[u8]) { assert!(a.len() == b.len());