Skip to content

Commit 4bed94c

Browse files
authored
Merge pull request #298 from fox0/clippy-manual_saturating_arithmetic
Fix clippy::manual_saturating_arithmetic
2 parents ba91157 + b18d92e commit 4bed94c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

users/talk.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ fn process_input_char(
834834
eprint!("\x1B[{};H\x1B[K", *top_line + 1);
835835
*top_line += 1;
836836

837-
if *top_line >= split_row.checked_sub(1).unwrap_or(0) {
837+
if *top_line >= split_row.saturating_sub(1) {
838838
eprint!("\x1B[{};H", 2);
839839
*top_line = 2;
840840
}
@@ -1331,12 +1331,8 @@ fn draw_terminal(split_row: u16, width: u16) -> io::Result<io::StdoutLock<'stati
13311331
// Move the cursor to the split row and draw the split line.
13321332
write!(handle, "\x1b[{};0H", split_row)?;
13331333
// Draw the horizontal split line (─) across the width of the terminal.
1334-
writeln!(
1335-
handle,
1336-
"└{:─<width$}┘",
1337-
"",
1338-
width = (width as usize).checked_sub(2).unwrap_or(0)
1339-
)?;
1334+
let width = usize::from(width.saturating_sub(2));
1335+
writeln!(handle, "└{:─<width$}┘", "", width = width)?;
13401336
// Move the cursor back to the top-left corner and then down by one line.
13411337
write!(handle, "\x1b[1;H")?;
13421338
write!(handle, "\x1B[1B")?;

0 commit comments

Comments
 (0)