From: Joshua Simmons Date: Sat, 18 Feb 2023 13:45:07 +0000 (+0100) Subject: Fix doctests X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=e5323aad2c56633c27fe912e5adeccc0ab60cdee;p=josh%2Fnarcissus Fix doctests --- diff --git a/narcissus-core/src/blake3/constant_time_eq.rs b/narcissus-core/src/blake3/constant_time_eq.rs index 7710a18..bb2f308 100644 --- a/narcissus-core/src/blake3/constant_time_eq.rs +++ b/narcissus-core/src/blake3/constant_time_eq.rs @@ -62,7 +62,7 @@ fn constant_time_ne(a: &[u8], b: &[u8]) -> u8 { /// # Examples /// /// ``` -/// use constant_time_eq::constant_time_eq; +/// use narcissus_core::blake3::constant_time_eq::constant_time_eq; /// /// assert!(constant_time_eq(b"foo", b"foo")); /// assert!(!constant_time_eq(b"foo", b"bar")); @@ -95,7 +95,7 @@ fn constant_time_ne_n(a: &[u8; N], b: &[u8; N]) -> u8 { /// # Examples /// /// ``` -/// use constant_time_eq::constant_time_eq_n; +/// use narcissus_core::blake3::constant_time_eq::constant_time_eq_n; /// /// assert!(constant_time_eq_n(&[3; 20], &[3; 20])); /// assert!(!constant_time_eq_n(&[3; 20], &[7; 20])); @@ -112,7 +112,7 @@ pub fn constant_time_eq_n(a: &[u8; N], b: &[u8; N]) -> bool { /// # Examples /// /// ``` -/// use constant_time_eq::constant_time_eq_16; +/// use narcissus_core::blake3::constant_time_eq::constant_time_eq_16; /// /// assert!(constant_time_eq_16(&[3; 16], &[3; 16])); /// assert!(!constant_time_eq_16(&[3; 16], &[7; 16])); @@ -127,7 +127,7 @@ pub fn constant_time_eq_16(a: &[u8; 16], b: &[u8; 16]) -> bool { /// # Examples /// /// ``` -/// use constant_time_eq::constant_time_eq_32; +/// use narcissus_core::blake3::constant_time_eq::constant_time_eq_32; /// /// assert!(constant_time_eq_32(&[3; 32], &[3; 32])); /// assert!(!constant_time_eq_32(&[3; 32], &[7; 32])); @@ -142,7 +142,7 @@ pub fn constant_time_eq_32(a: &[u8; 32], b: &[u8; 32]) -> bool { /// # Examples /// /// ``` -/// use constant_time_eq::constant_time_eq_64; +/// use narcissus_core::blake3::constant_time_eq::constant_time_eq_64; /// /// assert!(constant_time_eq_64(&[3; 64], &[3; 64])); /// assert!(!constant_time_eq_64(&[3; 64], &[7; 64])); diff --git a/narcissus-core/src/blake3/mod.rs b/narcissus-core/src/blake3/mod.rs index 6971b00..35a85fb 100644 --- a/narcissus-core/src/blake3/mod.rs +++ b/narcissus-core/src/blake3/mod.rs @@ -6,18 +6,15 @@ //! ``` //! # fn main() -> Result<(), Box> { //! // Hash an input all at once. -//! let hash1 = blake3::hash(b"foobarbaz"); +//! let hash1 = narcissus_core::blake3::hash(b"foobarbaz"); //! //! // Hash an input incrementally. -//! let mut hasher = blake3::Hasher::new(); +//! let mut hasher = narcissus_core::blake3::Hasher::new(); //! hasher.update(b"foo"); //! hasher.update(b"bar"); //! hasher.update(b"baz"); //! let hash2 = hasher.finalize(); //! assert_eq!(hash1, hash2); -//! -//! // Print a hash as hex. -//! println!("{}", hash1); //! # Ok(()) //! # } //! ``` @@ -753,11 +750,11 @@ fn parent_node_output( /// ``` /// # fn main() -> Result<(), Box> { /// // Hash an input incrementally. -/// let mut hasher = blake3::Hasher::new(); +/// let mut hasher = narcissus_core::blake3::Hasher::new(); /// hasher.update(b"foo"); /// hasher.update(b"bar"); /// hasher.update(b"baz"); -/// assert_eq!(hasher.finalize(), blake3::hash(b"foobarbaz")); +/// assert_eq!(hasher.finalize(), narcissus_core::blake3::hash(b"foobarbaz")); /// /// # Ok(()) /// # } diff --git a/narcissus-core/src/slice.rs b/narcissus-core/src/slice.rs index 36ed81b..5c469a4 100644 --- a/narcissus-core/src/slice.rs +++ b/narcissus-core/src/slice.rs @@ -466,32 +466,6 @@ pub fn as_chunks_mut(slice: &mut [T]) -> (&mut [[T; N]], &mut /// # Panics /// /// Panics if `N > len`. -/// -/// # Examples -/// -/// ``` -/// #![feature(split_array)] -/// -/// let v = &[1, 2, 3, 4, 5, 6][..]; -/// -/// { -/// let (left, right) = v.split_array_ref::<0>(); -/// assert_eq!(left, &[]); -/// assert_eq!(right, [1, 2, 3, 4, 5, 6]); -/// } -/// -/// { -/// let (left, right) = v.split_array_ref::<2>(); -/// assert_eq!(left, &[1, 2]); -/// assert_eq!(right, [3, 4, 5, 6]); -/// } -/// -/// { -/// let (left, right) = v.split_array_ref::<6>(); -/// assert_eq!(left, &[1, 2, 3, 4, 5, 6]); -/// assert_eq!(right, []); -/// } -/// ``` #[inline] #[track_caller] #[must_use] @@ -510,20 +484,6 @@ pub fn split_array_ref(slice: &[T]) -> (&[T; N], &[T]) { /// # Panics /// /// Panics if `N > len`. -/// -/// # Examples -/// -/// ``` -/// #![feature(split_array)] -/// -/// let mut v = &mut [1, 0, 3, 0, 5, 6][..]; -/// let (left, right) = v.split_array_mut::<2>(); -/// assert_eq!(left, &mut [1, 0]); -/// assert_eq!(right, [3, 0, 5, 6]); -/// left[1] = 2; -/// right[1] = 4; -/// assert_eq!(v, [1, 2, 3, 4, 5, 6]); -/// ``` #[inline] #[track_caller] #[must_use] @@ -543,32 +503,6 @@ pub fn split_array_mut(slice: &mut [T]) -> (&mut [T; N], &mut /// # Panics /// /// Panics if `N > len`. -/// -/// # Examples -/// -/// ``` -/// #![feature(split_array)] -/// -/// let v = &[1, 2, 3, 4, 5, 6][..]; -/// -/// { -/// let (left, right) = v.rsplit_array_ref::<0>(); -/// assert_eq!(left, [1, 2, 3, 4, 5, 6]); -/// assert_eq!(right, &[]); -/// } -/// -/// { -/// let (left, right) = v.rsplit_array_ref::<2>(); -/// assert_eq!(left, [1, 2, 3, 4]); -/// assert_eq!(right, &[5, 6]); -/// } -/// -/// { -/// let (left, right) = v.rsplit_array_ref::<6>(); -/// assert_eq!(left, []); -/// assert_eq!(right, &[1, 2, 3, 4, 5, 6]); -/// } -/// ``` #[inline] #[must_use] pub fn rsplit_array_ref(slice: &[T]) -> (&[T], &[T; N]) { @@ -588,20 +522,6 @@ pub fn rsplit_array_ref(slice: &[T]) -> (&[T], &[T; N]) { /// # Panics /// /// Panics if `N > len`. -/// -/// # Examples -/// -/// ``` -/// #![feature(split_array)] -/// -/// let mut v = &mut [1, 0, 3, 0, 5, 6][..]; -/// let (left, right) = v.rsplit_array_mut::<4>(); -/// assert_eq!(left, [1, 0]); -/// assert_eq!(right, &mut [3, 0, 5, 6]); -/// left[1] = 2; -/// right[1] = 4; -/// assert_eq!(v, [1, 2, 3, 4, 5, 6]); -/// ``` #[inline] #[must_use] pub fn rsplit_array_mut(slice: &mut [T]) -> (&mut [T], &mut [T; N]) {