Skip to content

Commit

Permalink
add inline annotation to concrete impls
Browse files Browse the repository at this point in the history
otherwise they wouldn't be eligible for cross-crate inlining
  • Loading branch information
the8472 committed Jun 22, 2023
1 parent 070ce23 commit 1bc095c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/core/src/iter/adapters/step_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ macro_rules! spec_int_ranges {
}
}

#[inline]
fn spec_size_hint(&self) -> (usize, Option<usize>) {
let remaining = self.iter.end as usize;
(remaining, Some(remaining))
Expand All @@ -403,11 +404,13 @@ macro_rules! spec_int_ranges {
// The methods below are all copied from the Iterator trait default impls.
// We have to repeat them here so that the specialization overrides the StepByImpl defaults

#[inline]
fn spec_nth(&mut self, n: usize) -> Option<Self::Item> {
self.advance_by(n).ok()?;
self.next()
}

#[inline]
fn spec_try_fold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
where
F: FnMut(Acc, Self::Item) -> R,
Expand Down Expand Up @@ -449,6 +452,7 @@ macro_rules! spec_int_ranges_r {

impl StepByBackImpl<Range<$t>> for StepBy<Range<$t>> {

#[inline]
fn spec_next_back(&mut self) -> Option<Self::Item>
where Range<$t>: DoubleEndedIterator + ExactSizeIterator,
{
Expand All @@ -466,6 +470,7 @@ macro_rules! spec_int_ranges_r {
// The methods below are all copied from the Iterator trait default impls.
// We have to repeat them here so that the specialization overrides the StepByImplBack defaults

#[inline]
fn spec_nth_back(&mut self, n: usize) -> Option<Self::Item>
where Self: DoubleEndedIterator,
{
Expand All @@ -475,6 +480,7 @@ macro_rules! spec_int_ranges_r {
self.next_back()
}

#[inline]
fn spec_try_rfold<Acc, F, R>(&mut self, init: Acc, mut f: F) -> R
where
Self: DoubleEndedIterator,
Expand All @@ -488,6 +494,7 @@ macro_rules! spec_int_ranges_r {
try { accum }
}

#[inline]
fn spec_rfold<Acc, F>(mut self, init: Acc, mut f: F) -> Acc
where
Self: DoubleEndedIterator,
Expand Down

0 comments on commit 1bc095c

Please sign in to comment.