Closed
Description
If I've got a nasty blob like:
fn neighbor_count(&self, x: usize, y: usize) -> i32 {
let mut count = 0;
if x >= 1 {
if y >= 1 && self.ca_grid[x - 1][y - 1] {
count += 1
}
if self.ca_grid[x - 1][y] {
count += 1
}
if self.ca_grid[x - 1][y + 1] {
count += 1
}
}
if y >= 1 && self.ca_grid[x][y - 1] {
count += 1
}
if self.ca_grid[x][y + 1] {
count += 1
}
if y >= 1 && self.ca_grid[x + 1][y - 1] {
count += 1
}
if self.ca_grid[x + 1][y] {
count += 1
}
if self.ca_grid[x + 1][y + 1] {
count += 1
}
count
}
Ideally those ifs would get flattened if I they fit under single_line_if_else_max_width, but rustfmt seems intent on breaking them up. Am I missing something, or is this expected?
Metadata
Metadata
Assignees
Labels
No labels