diff --git a/src/lib.rs b/src/lib.rs index 882a880..42c04c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1520,6 +1520,7 @@ impl SmallVec { // At this point we either consumed all capacity or the iterator is exhausted (fused) if let Some(item) = iter.next() { self.push(item); + len += 1; } else { return; } diff --git a/src/tests.rs b/src/tests.rs index 2f0a1f2..925eb3b 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1151,6 +1151,15 @@ fn collect_from_iter() { let _y: SmallVec = SmallVec::from_iter(iter); } +#[test] +fn test_collect_with_spill() { + let input = "0123456"; + let collected: SmallVec = input + .chars() + .collect(); + assert_eq!(collected, &['0', '1', '2', '3', '4', '5', '6']); +} + #[test] fn test_spare_capacity_mut() { let mut v: SmallVec = SmallVec::new();