diff --git a/src/wiwi/iter/size_hint.rs.html b/src/wiwi/iter/size_hint.rs.html index fc12b3d2d..1730bc307 100644 --- a/src/wiwi/iter/size_hint.rs.html +++ b/src/wiwi/iter/size_hint.rs.html @@ -217,6 +217,14 @@ 217 218 219 +220 +221 +222 +223 +224 +225 +226 +227
use super::Iter;
 
 #[derive(Debug)]
@@ -272,7 +280,7 @@
 
 	#[inline]
 	unsafe fn single(bound: SizeHintBound) -> Self {
-		Self::with_inner(SizeHintInner::Lower { bound })
+		Self::with_inner(SizeHintInner::Single { bound })
 	}
 
 	#[inline]
@@ -327,12 +335,20 @@
 
 	#[inline]
 	pub unsafe fn range_hard(lower: usize, upper: usize) -> Self {
-		Self::range(SizeHintBound::Hard { count: lower }, SizeHintBound::Hard { count: upper })
+		if lower == upper {
+			Self::single(SizeHintBound::Hard { count: lower })
+		} else {
+			Self::range(SizeHintBound::Hard { count: lower }, SizeHintBound::Hard { count: upper })
+		}
 	}
 
 	#[inline]
 	pub unsafe fn range_estimate(lower: usize, upper: usize) -> Self {
-		Self::range(SizeHintBound::Estimate { count: lower }, SizeHintBound::Estimate { count: upper })
+		if lower == upper {
+			Self::single(SizeHintBound::Estimate { count: lower })
+		} else {
+			Self::range(SizeHintBound::Estimate { count: lower }, SizeHintBound::Estimate { count: upper })
+		}
 	}
 
 	#[inline]
diff --git a/src/wiwi/iter/tuple.rs.html b/src/wiwi/iter/tuple.rs.html
index ed6d5d860..102e93bdf 100644
--- a/src/wiwi/iter/tuple.rs.html
+++ b/src/wiwi/iter/tuple.rs.html
@@ -645,9 +645,6 @@
 645
 646
 647
-648
-649
-650
 
use super::{ IntoIter, Iter, SizeHintBound, SizeHintImpl, SizeHintInner, SizeHintMarker };
 use std::ptr;
 
@@ -1171,116 +1168,113 @@
 mod tests {
 	use super::*;
 
-	// #[test]
-	// fn min_size_hint() {
-	// 	struct Checker {
-	// 		h1: SizeHint,
-	// 		h2: SizeHint,
-	// 		expected: SizeHint,
-	// 	}
-
-	// 	impl Checker {
-	// 		fn check(self) {
-	// 			let Self { h1, h2, expected } = self;
-
-	// 			// check both ways
-	// 			assert_eq!(unsafe { super::min_size_hint(h1.clone(), h2.clone()) }, expected);
-	// 			assert_eq!(unsafe { super::min_size_hint(h2, h1) }, expected);
-	// 		}
-	// 	}
-
-	// 	unsafe {
-	// 		// all unknown
-	// 		Checker {
-	// 			h1: SizeHint::unknown(),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::unknown()
-	// 		}.check();
-
-	// 		// one lower or upper estimate
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_estimate(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::new().with_lower_estimate(10)
-	// 		}.check();
-	// 		Checker {
-	// 			h1: SizeHint::new().with_upper_estimate(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::new().with_upper_estimate(10)
-	// 		}.check();
-
-	// 		// one both estimate
-	// 		Checker {
-	// 			h1: SizeHint::estimate(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::estimate(10)
-	// 		}.check();
-
-	// 		// one lower, other upper estimate
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_estimate(10),
-	// 			h2: SizeHint::new().with_upper_estimate(10),
-	// 			expected: SizeHint::estimate(10)
-	// 		}.check();
-
-	// 		// hard bound + unknown
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_hard_bound(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::new().with_lower_estimate(10)
-	// 		}.check();
-	// 		Checker {
-	// 			h1: SizeHint::new().with_upper_hard_bound(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::new().with_upper_estimate(10)
-	// 		}.check();
-	// 		Checker {
-	// 			h1: SizeHint::hard_bound(10),
-	// 			h2: SizeHint::unknown(),
-	// 			expected: SizeHint::estimate(10)
-	// 		}.check();
-
-	// 		// hard bound + estimate
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_hard_bound(10),
-	// 			h2: SizeHint::new().with_upper_estimate(10),
-	// 			expected: SizeHint::estimate(10)
-	// 		}.check();
-	// 		Checker {
-	// 			h1: SizeHint::new().with_upper_hard_bound(10),
-	// 			h2: SizeHint::new().with_lower_estimate(10),
-	// 			expected: SizeHint::estimate(10)
-	// 		}.check();
-
-	// 		// differing estimates
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_estimate(10).with_upper_estimate(5),
-	// 			h2: SizeHint::new().with_upper_estimate(10).with_lower_estimate(5),
-	// 			expected: SizeHint::estimate(5)
-	// 		}.check();
-
-	// 		// differing hard
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_hard_bound(10).with_upper_hard_bound(5),
-	// 			h2: SizeHint::new().with_upper_hard_bound(10).with_lower_hard_bound(5),
-	// 			expected: SizeHint::hard_bound(5)
-	// 		}.check();
-
-	// 		// differing hard + estimate
-	// 		Checker {
-	// 			h1: SizeHint::new().with_lower_hard_bound(10).with_upper_hard_bound(7),
-	// 			h2: SizeHint::new().with_upper_estimate(12).with_lower_estimate(9),
-	// 			expected: SizeHint::new().with_lower_estimate(9).with_upper_estimate(7)
-	// 		}.check();
-	// 		Checker {
-	// 			h1: SizeHint::new().with_upper_hard_bound(10).with_lower_estimate(7),
-	// 			h2: SizeHint::new().with_upper_estimate(12).with_lower_hard_bound(9),
-	// 			expected: SizeHint::new().with_upper_estimate(10).with_lower_estimate(7)
-	// 		}.check();
-	// 	}
-	// }
-
-	#[test]
+	#[test]
+	fn min_size_hint() {
+		macro_rules! check {
+			{
+				h1: $h1:expr,
+				h2: $h2:expr,
+				expected: $expected:expr
+			} => {
+				unsafe {
+					assert_eq!(super::min_size_hint($h1, $h2), $expected);
+					assert_eq!(super::min_size_hint($h2, $h1), $expected);
+				}
+			}
+		}
+
+
+			// all unknown
+			check! {
+				h1: SizeHintImpl::unknown(),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::unknown()
+			}
+
+			// one lower or upper estimate
+			check! {
+				h1: SizeHintImpl::lower_estimate(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::lower_estimate(10)
+			}
+			check! {
+				h1: SizeHintImpl::upper_estimate(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::upper_estimate(10)
+			}
+
+			// one both estimate
+			check! {
+				h1: SizeHintImpl::estimate(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::estimate(10)
+			}
+
+			// one lower, other upper estimate
+			check! {
+				h1: SizeHintImpl::lower_estimate(10),
+				h2: SizeHintImpl::upper_estimate(10),
+				expected: SizeHintImpl::estimate(10)
+			}
+
+			// // hard bound + unknown
+			check! {
+				h1: SizeHintImpl::lower_hard(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::lower_estimate(10)
+			}
+			check! {
+				h1: SizeHintImpl::upper_hard(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::upper_estimate(10)
+			}
+			check! {
+				h1: SizeHintImpl::hard(10),
+				h2: SizeHintImpl::unknown(),
+				expected: SizeHintImpl::estimate(10)
+			}
+
+			// hard bound + estimate
+			check! {
+				h1: SizeHintImpl::lower_hard(10),
+				h2: SizeHintImpl::upper_estimate(10),
+				expected: SizeHintImpl::estimate(10)
+			}
+			check! {
+				h1: SizeHintImpl::upper_hard(10),
+				h2: SizeHintImpl::lower_estimate(10),
+				expected: SizeHintImpl::estimate(10)
+			}
+
+			// differing estimates
+			check! {
+				// actual range values makes no sense, but whatever lol
+				h1: SizeHintImpl::range_estimate(10, 5),
+				h2: SizeHintImpl::range_estimate(5, 10),
+				expected: SizeHintImpl::estimate(5)
+			}
+
+			// differing hard
+			check! {
+				h1: SizeHintImpl::range_hard(10, 5),
+				h2: SizeHintImpl::range_hard(5, 10),
+				expected: SizeHintImpl::hard(5)
+			}
+
+			// differing hard + estimate
+			check! {
+				h1: SizeHintImpl::range_hard(10, 7),
+				h2: SizeHintImpl::range_estimate(9, 12),
+				expected: SizeHintImpl::range_estimate(9, 7)
+			}
+			check! {
+				h1: SizeHintImpl::range_lestimate_uhard(7, 10),
+				h2: SizeHintImpl::range_lhard_uestimate(9, 12),
+				expected: SizeHintImpl::range_estimate(7, 10)
+			}
+	}
+
+	#[test]
 	fn size_hint() {
 		let mut iter = (vec![1u8, 2, 3, 4, 5], vec![7usize, 6, 5, 4, 3, 2, 1]).into_wiwi_iter();
 
diff --git a/wiwi/index.html b/wiwi/index.html
index da70379e7..c5f1c0c24 100644
--- a/wiwi/index.html
+++ b/wiwi/index.html
@@ -71,7 +71,7 @@ 

9e161e70.

+

These docs have been built from commit 97bcc0af.


  1. Based on the benchmark available in this repo: wiwi is about 21.5x faster in encode, and 7.5x faster in decode. I want better benchmarks though. For now the hex crate also provides more flexibility, whereas wiwi::hex just exposes encode_hex, encode_upper_hex, and decode_hex functions.  

  2. Based on the benchmark available in this repo: wiwi is about 1.4x faster in encode, and 2.2x faster in decode. I want better benchmarks though. There is no functionality that the z85 crate provides, that we don’t also provide (encode_z85 and decode_z85 functions). 

Modules§