mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 06:43:20 +03:00
Use checked
This commit is contained in:
@@ -184,7 +184,7 @@ pub fn to_wide(&self, enc: WideEncoding, line_col: LineCol) -> Option<WideLineCo
|
||||
if let Some(wide_chars) = self.line_wide_chars.get(&line_col.line) {
|
||||
for c in wide_chars.iter() {
|
||||
if u32::from(c.end) <= line_col.col {
|
||||
col -= u32::from(c.len()) - c.wide_len(enc);
|
||||
col = col.checked_sub(u32::from(c.len()) - c.wide_len(enc))?;
|
||||
} else {
|
||||
// From here on, all utf16 characters come *after* the character we are mapping,
|
||||
// so we don't need to take them into account
|
||||
@@ -201,7 +201,7 @@ pub fn to_utf8(&self, enc: WideEncoding, line_col: WideLineCol) -> Option<LineCo
|
||||
if let Some(wide_chars) = self.line_wide_chars.get(&line_col.line) {
|
||||
for c in wide_chars.iter() {
|
||||
if col > u32::from(c.start) {
|
||||
col += u32::from(c.len()) - c.wide_len(enc) as u32;
|
||||
col = col.checked_add(u32::from(c.len()) - c.wide_len(enc))?;
|
||||
} else {
|
||||
// From here on, all utf16 characters come *after* the character we are mapping,
|
||||
// so we don't need to take them into account
|
||||
|
||||
Reference in New Issue
Block a user