Skip to content

Commit 744dc8c

Browse files
committed
Use checked_sub
1 parent 617e64c commit 744dc8c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/librustdoc/html/format.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ impl clean::FnDecl {
14391439
write!(f, "\n{}", Indent(n + 4))?;
14401440
}
14411441

1442-
let last_input_index = self.inputs.values.len() - 1;
1442+
let last_input_index = self.inputs.values.len().checked_sub(1);
14431443
for (i, input) in self.inputs.values.iter().enumerate() {
14441444
if let Some(selfty) = input.to_self() {
14451445
match selfty {
@@ -1473,11 +1473,12 @@ impl clean::FnDecl {
14731473
write!(f, "{}: ", input.name)?;
14741474
input.type_.print(cx).fmt(f)?;
14751475
}
1476-
match line_wrapping_indent {
1477-
None if i == last_input_index => (),
1478-
None => write!(f, ", ")?,
1479-
Some(_n) if i == last_input_index => write!(f, ",\n")?,
1480-
Some(n) => write!(f, ",\n{}", Indent(n + 4))?,
1476+
match (line_wrapping_indent, last_input_index) {
1477+
(_, None) => (),
1478+
(None, Some(last_i)) if i != last_i => write!(f, ", ")?,
1479+
(None, Some(_)) => (),
1480+
(Some(n), Some(last_i)) if i != last_i => write!(f, ",\n{}", Indent(n + 4))?,
1481+
(Some(_), Some(_)) => write!(f, ",\n")?,
14811482
}
14821483
}
14831484

0 commit comments

Comments
 (0)