Skip to content

Commit 8ee85f5

Browse files
committed
Amend AsciiChar preconditions
1 parent 4e24588 commit 8ee85f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/iter/range.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl Step for AsciiChar {
570570
Some(unsafe { AsciiChar::from_u8_unchecked(end) })
571571
}
572572

573-
#[requires((start.to_u8() as u32).checked_add(count as u32).is_some())]
573+
#[requires(count < 256 && start.to_u8().checked_add(count as u8).is_some())]
574574
#[inline]
575575
unsafe fn forward_unchecked(start: AsciiChar, count: usize) -> AsciiChar {
576576
// SAFETY: Caller asserts that result is a valid ASCII character,
@@ -581,7 +581,7 @@ impl Step for AsciiChar {
581581
unsafe { AsciiChar::from_u8_unchecked(end) }
582582
}
583583

584-
#[requires((start.to_u8() as u32).checked_sub(count as u32).is_some())]
584+
#[requires(count < 256 && start.to_u8().checked_sub(count as u8).is_some())]
585585
#[inline]
586586
unsafe fn backward_unchecked(start: AsciiChar, count: usize) -> AsciiChar {
587587
// SAFETY: Caller asserts that result is a valid ASCII character,

0 commit comments

Comments
 (0)