diff --git a/crates/ruff_python_codegen/src/stylist.rs b/crates/ruff_python_codegen/src/stylist.rs index 37115690a140f..fc9e43bfb6926 100644 --- a/crates/ruff_python_codegen/src/stylist.rs +++ b/crates/ruff_python_codegen/src/stylist.rs @@ -106,13 +106,7 @@ fn detect_indention(tokens: &[LexResult], locator: &Locator) -> Indentation { } TokenKind::NonLogicalNewline => { let line = locator.line(range.end()); - let indent_index = line.char_indices().find_map(|(i, c)| { - if c.is_whitespace() { - None - } else { - Some(i) - } - }); + let indent_index = line.find(|c: char| !c.is_whitespace()); if let Some(indent_index) = indent_index { if indent_index > 0 { let whitespace = &line[..indent_index];