From 356eb89210b29bbb738fa2f2f07f9032fc2c5bf5 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Tue, 19 Sep 2023 16:13:25 +0200 Subject: [PATCH 1/3] Fix ignored doctest of `size_hint::mul` This doctest can not run because this function (and module) is private. --- src/size_hint.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/size_hint.rs b/src/size_hint.rs index 7ba6f443b..857e0c4c6 100644 --- a/src/size_hint.rs +++ b/src/size_hint.rs @@ -38,20 +38,6 @@ pub fn sub_scalar(sh: SizeHint, x: usize) -> SizeHint { } /// Multiply `SizeHint` correctly -/// -/// ```ignore -/// use std::usize; -/// use itertools::size_hint; -/// -/// assert_eq!(size_hint::mul((3, Some(4)), (3, Some(4))), -/// (9, Some(16))); -/// -/// assert_eq!(size_hint::mul((3, Some(4)), (usize::MAX, None)), -/// (usize::MAX, None)); -/// -/// assert_eq!(size_hint::mul((3, None), (0, Some(0))), -/// (0, Some(0))); -/// ``` #[inline] pub fn mul(a: SizeHint, b: SizeHint) -> SizeHint { let low = a.0.saturating_mul(b.0); @@ -100,3 +86,10 @@ pub fn min(a: SizeHint, b: SizeHint) -> SizeHint { }; (lower, upper) } + +#[test] +fn mul_size_hints() { + assert_eq!(mul((3, Some(4)), (3, Some(4))), (9, Some(16))); + assert_eq!(mul((3, Some(4)), (usize::MAX, None)), (usize::MAX, None)); + assert_eq!(mul((3, None), (0, Some(0))), (0, Some(0))); +} From fe51f6f70ecc26a54c3bfa5fa1d9472b7ed1fafa Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Tue, 19 Sep 2023 16:21:16 +0200 Subject: [PATCH 2/3] `assert_equal` doctest should not be ignored but panic --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7dc40370b..914ad0b13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3981,9 +3981,10 @@ where /// **Panics** on assertion failure with a message that shows the /// two iteration elements. /// -/// ```ignore +/// ```should_panic +/// # use itertools::assert_equal; /// assert_equal("exceed".split('c'), "excess".split('c')); -/// // ^PANIC: panicked at 'Failed assertion Some("eed") == Some("ess") for iteration 1', +/// // ^PANIC: panicked at 'Failed assertion Some("eed") == Some("ess") for iteration 1'. /// ``` pub fn assert_equal(a: I, b: J) where From dac0a1a8183e99a4476f64e98b0d68fc7b9a2b97 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet Date: Tue, 19 Sep 2023 16:27:40 +0200 Subject: [PATCH 3/3] `fold_ok` small doctest: no run But it should compile at it is code. --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 914ad0b13..06c42c30f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2373,7 +2373,9 @@ pub trait Itertools: Iterator { /// For example the sequence *Ok(1), Ok(2), Ok(3)* will result in a /// computation like this: /// - /// ```ignore + /// ```no_run + /// # let start = 0; + /// # let f = |x, y| x + y; /// let mut accum = start; /// accum = f(accum, 1); /// accum = f(accum, 2);