diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-05-13 00:43:15 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2022-05-13 00:43:15 -0700 |
| commit | e8fc7ba6a756628b3226e002e3f3e54ddf14fa04 (patch) | |
| tree | fed3e2df526716985321ccabf1cee9b6c6bd19a7 | |
| parent | 83595f9242ad9e8a7da091f65d450e44e4434f89 (diff) | |
Slap #[inline] on all the ByRefSized methods, per the8472's suggestion
| -rw-r--r-- | library/core/src/iter/adapters/by_ref_sized.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/core/src/iter/adapters/by_ref_sized.rs b/library/core/src/iter/adapters/by_ref_sized.rs index 890faa5975f..bf2e3e182e2 100644 --- a/library/core/src/iter/adapters/by_ref_sized.rs +++ b/library/core/src/iter/adapters/by_ref_sized.rs @@ -9,22 +9,27 @@ pub(crate) struct ByRefSized<'a, I>(pub &'a mut I); impl<I: Iterator> Iterator for ByRefSized<'_, I> { type Item = I::Item; + #[inline] fn next(&mut self) -> Option<Self::Item> { self.0.next() } + #[inline] fn size_hint(&self) -> (usize, Option<usize>) { self.0.size_hint() } + #[inline] fn advance_by(&mut self, n: usize) -> Result<(), usize> { self.0.advance_by(n) } + #[inline] fn nth(&mut self, n: usize) -> Option<Self::Item> { self.0.nth(n) } + #[inline] fn fold<B, F>(self, init: B, f: F) -> B where F: FnMut(B, Self::Item) -> B, @@ -32,6 +37,7 @@ impl<I: Iterator> Iterator for ByRefSized<'_, I> { self.0.fold(init, f) } + #[inline] fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where F: FnMut(B, Self::Item) -> R, @@ -42,18 +48,22 @@ impl<I: Iterator> Iterator for ByRefSized<'_, I> { } impl<I: DoubleEndedIterator> DoubleEndedIterator for ByRefSized<'_, I> { + #[inline] fn next_back(&mut self) -> Option<Self::Item> { self.0.next_back() } + #[inline] fn advance_back_by(&mut self, n: usize) -> Result<(), usize> { self.0.advance_back_by(n) } + #[inline] fn nth_back(&mut self, n: usize) -> Option<Self::Item> { self.0.nth_back(n) } + #[inline] fn rfold<B, F>(self, init: B, f: F) -> B where F: FnMut(B, Self::Item) -> B, @@ -61,6 +71,7 @@ impl<I: DoubleEndedIterator> DoubleEndedIterator for ByRefSized<'_, I> { self.0.rfold(init, f) } + #[inline] fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where F: FnMut(B, Self::Item) -> R, |
