Skip to content

Commit

Permalink
allow inlining Step methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Feb 29, 2024
1 parent b62d1d9 commit 8da3546
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ impl VirtAddr {
}

// FIXME: Move this into the `Step` impl, once `Step` is stabilized.
#[inline]
pub(crate) fn forward_checked_impl(start: Self, count: usize) -> Option<Self> {
let offset = u64::try_from(count).ok()?;
if offset > ADDRESS_SPACE_SIZE {
Expand Down Expand Up @@ -343,14 +344,17 @@ impl Sub<VirtAddr> for VirtAddr {

#[cfg(feature = "step_trait")]
impl Step for VirtAddr {
#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
Self::steps_between_impl(start, end)
}

#[inline]
fn forward_checked(start: Self, count: usize) -> Option<Self> {
Self::forward_checked_impl(start, count)
}

#[inline]
fn backward_checked(start: Self, count: usize) -> Option<Self> {
let offset = u64::try_from(count).ok()?;
if offset > ADDRESS_SPACE_SIZE {
Expand Down

0 comments on commit 8da3546

Please sign in to comment.