Auto merge of #49551 - scottmcm:deprecate-offset_to, r=KodrAus
Deprecate offset_to; switch core&alloc to using offset_from instead Bonus: might make code than uses `.len()` on slice iterators faster cc https://github.com/rust-lang/rust/issues/41079
This commit is contained in:
@@ -2394,9 +2394,10 @@ impl<T> Iterator for IntoIter<T> {
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
let exact = match self.ptr.offset_to(self.end) {
|
||||
Some(x) => x as usize,
|
||||
None => (self.end as usize).wrapping_sub(self.ptr as usize),
|
||||
let exact = if mem::size_of::<T>() == 0 {
|
||||
(self.end as usize).wrapping_sub(self.ptr as usize)
|
||||
} else {
|
||||
unsafe { self.end.offset_from(self.ptr) as usize }
|
||||
};
|
||||
(exact, Some(exact))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user