Skip to content

Commit 07490e9

Browse files
committed
Ipv6Addr
1 parent ab6312f commit 07490e9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/iter/range.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,15 @@ impl Step for Ipv6Addr {
645645
u128::backward_checked(start.to_bits(), count).map(Ipv6Addr::from_bits)
646646
}
647647

648+
#[requires(start.to_bits().checked_add(count as u128).is_some())]
648649
#[inline]
649650
unsafe fn forward_unchecked(start: Ipv6Addr, count: usize) -> Ipv6Addr {
650651
// SAFETY: Since u128 and Ipv6Addr are losslessly convertible,
651652
// this is as safe as the u128 version.
652653
Ipv6Addr::from_bits(unsafe { u128::forward_unchecked(start.to_bits(), count) })
653654
}
654655

656+
#[requires(start.to_bits().checked_sub(count as u128).is_some())]
655657
#[inline]
656658
unsafe fn backward_unchecked(start: Ipv6Addr, count: usize) -> Ipv6Addr {
657659
// SAFETY: Since u128 and Ipv6Addr are losslessly convertible,

0 commit comments

Comments
 (0)