Skip to content

Commit 2e1beb1

Browse files
committed
Fixed the (1, Some(0)) size_hint bug
1 parent 87d7f9a commit 2e1beb1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

library/core/src/iter/adapters/dedup.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ where
5050
}
5151

5252
fn size_hint(&self) -> (usize, Option<usize>) {
53-
let min = self.last.as_ref().map(|_| 1).unwrap_or(0);
54-
let max = self.inner.size_hint().1;
55-
(min, max)
53+
if self.last.is_some() { (1, self.inner.size_hint().1) } else { (0, Some(0)) }
5654
}
5755
}
5856

@@ -107,9 +105,7 @@ where
107105
}
108106

109107
fn size_hint(&self) -> (usize, Option<usize>) {
110-
let min = self.last.as_ref().map(|_| 1).unwrap_or(0);
111-
let max = self.inner.size_hint().1;
112-
(min, max)
108+
if self.last.is_some() { (1, self.inner.size_hint().1) } else { (0, Some(0)) }
113109
}
114110
}
115111

@@ -165,8 +161,6 @@ where
165161
}
166162

167163
fn size_hint(&self) -> (usize, Option<usize>) {
168-
let min = self.last.as_ref().map(|_| 1).unwrap_or(0);
169-
let max = self.inner.size_hint().1;
170-
(min, max)
164+
if self.last.is_some() { (1, self.inner.size_hint().1) } else { (0, Some(0)) }
171165
}
172166
}

0 commit comments

Comments
 (0)