Skip to content

Commit

Permalink
Use checked_sub
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergi-Ferrez committed Jun 4, 2024
1 parent 617e64c commit 744dc8c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ impl clean::FnDecl {
write!(f, "\n{}", Indent(n + 4))?;
}

let last_input_index = self.inputs.values.len() - 1;
let last_input_index = self.inputs.values.len().checked_sub(1);
for (i, input) in self.inputs.values.iter().enumerate() {
if let Some(selfty) = input.to_self() {
match selfty {
Expand Down Expand Up @@ -1473,11 +1473,12 @@ impl clean::FnDecl {
write!(f, "{}: ", input.name)?;
input.type_.print(cx).fmt(f)?;
}
match line_wrapping_indent {
None if i == last_input_index => (),
None => write!(f, ", ")?,
Some(_n) if i == last_input_index => write!(f, ",\n")?,
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
match (line_wrapping_indent, last_input_index) {
(_, None) => (),
(None, Some(last_i)) if i != last_i => write!(f, ", ")?,
(None, Some(_)) => (),
(Some(n), Some(last_i)) if i != last_i => write!(f, ",\n{}", Indent(n + 4))?,
(Some(_), Some(_)) => write!(f, ",\n")?,
}
}

Expand Down

0 comments on commit 744dc8c

Please sign in to comment.