Add safety annotations in iter::range
This commit is contained in:
parent
c25b82f5bb
commit
27d1cd857e
1 changed files with 4 additions and 0 deletions
|
|
@ -427,6 +427,8 @@ unsafe impl Step for char {
|
|||
res = Step::forward_checked(res, 0x800)?;
|
||||
}
|
||||
if res <= char::MAX as u32 {
|
||||
// SAFETY: res is a valid unicode scalar
|
||||
// (below 0x110000 and not in 0xD800..0xE000)
|
||||
Some(unsafe { char::from_u32_unchecked(res) })
|
||||
} else {
|
||||
None
|
||||
|
|
@ -440,6 +442,8 @@ unsafe impl Step for char {
|
|||
if start >= 0xE000 && 0xE000 > res {
|
||||
res = Step::backward_checked(res, 0x800)?;
|
||||
}
|
||||
// SAFETY: res is a valid unicode scalar
|
||||
// (below 0x110000 and not in 0xD800..0xE000)
|
||||
Some(unsafe { char::from_u32_unchecked(res) })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue