mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-30 21:16:27 +03:00
Merge pull request #20601 from A4-Tacks/indent-level-add-assign
Add `ops::AddAssign` implement for IndentLevel
This commit is contained in:
@@ -33,7 +33,7 @@ pub(crate) fn unwrap_tuple(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option
|
||||
let (ty, init, prefix, suffix) = match &let_stmt {
|
||||
Either::Left(let_stmt) => (let_stmt.ty(), let_stmt.initializer()?, "", ";"),
|
||||
Either::Right(let_expr) => {
|
||||
indent_level = indent_level + 1;
|
||||
indent_level += 1;
|
||||
(None, let_expr.expr()?, "&& ", "")
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option<Vec<
|
||||
let mut indent = IndentLevel::from_node(if_expr.syntax());
|
||||
let has_parent_if_expr = if_expr.syntax().parent().and_then(ast::IfExpr::cast).is_some();
|
||||
if has_parent_if_expr {
|
||||
indent = indent + 1;
|
||||
indent += 1;
|
||||
}
|
||||
let else_replacement = match if_expr.else_branch()? {
|
||||
ast::ElseBranch::Block(block) => block
|
||||
|
||||
@@ -43,6 +43,12 @@ fn add(self, rhs: u8) -> IndentLevel {
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::AddAssign<u8> for IndentLevel {
|
||||
fn add_assign(&mut self, rhs: u8) {
|
||||
self.0 += rhs;
|
||||
}
|
||||
}
|
||||
|
||||
impl IndentLevel {
|
||||
pub fn single() -> IndentLevel {
|
||||
IndentLevel(0)
|
||||
|
||||
Reference in New Issue
Block a user