diff options
| author | The8472 <git@infinite-source.de> | 2021-08-03 21:32:36 +0200 |
|---|---|---|
| committer | The8472 <git@infinite-source.de> | 2021-08-03 21:32:36 +0200 |
| commit | e44d39a5b78376cb0d55c440e3bf0d08b492c61c (patch) | |
| tree | ab084cd3b607ff540574712c3518ab1c5219a213 | |
| parent | d5fd37f00f1ec5e4a4b0d87f5af0b93f36aab271 (diff) | |
| download | rust-e44d39a5b78376cb0d55c440e3bf0d08b492c61c.tar.gz rust-e44d39a5b78376cb0d55c440e3bf0d08b492c61c.zip | |
#[inline] slice::advance_by
| -rw-r--r-- | library/core/src/slice/iter/macros.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/slice/iter/macros.rs b/library/core/src/slice/iter/macros.rs index 791a88dd97f..cf15756868e 100644 --- a/library/core/src/slice/iter/macros.rs +++ b/library/core/src/slice/iter/macros.rs @@ -185,8 +185,9 @@ macro_rules! iterator { } } + #[inline] fn advance_by(&mut self, n: usize) -> Result<(), usize> { - let advance = cmp::min(n, len!(self)); + let advance = cmp::min(len!(self), n); // SAFETY: By construction, `advance` does not exceed `self.len()`. unsafe { self.post_inc_start(advance as isize) }; if advance == n { Ok(()) } else { Err(advance) } @@ -381,7 +382,7 @@ macro_rules! iterator { #[inline] fn advance_back_by(&mut self, n: usize) -> Result<(), usize> { - let advance = cmp::min(n, len!(self)); + let advance = cmp::min(len!(self), n); // SAFETY: By construction, `advance` does not exceed `self.len()`. unsafe { self.pre_dec_end(advance as isize) }; if advance == n { Ok(()) } else { Err(advance) } |
