fix(building/utils): fix subtract with overflow
@@ -22,12 +22,19 @@ impl Display for FormatVec {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
let mut comma_separated = String::new();
- for s in &self.0[0..self.0.len() - 1] {
+ let v = &self.0;
+
+ if v.is_empty() {
+ return Ok(());
+ }
+
+ for s in &self.0[0..v.len() - 1] {
comma_separated.push_str(s);
comma_separated.push_str(", ");
}
- comma_separated.push_str(&self.0[self.0.len() - 1]);
+ comma_separated.push_str(&self.0[v.len() - 1]);
+
write!(f, "{}", comma_separated)
}
}
