removed double matching
This commit is contained in:
parent
771c87f890
commit
035a373a6a
@ -52,10 +52,10 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
|
||||
}
|
||||
}
|
||||
|
||||
let ref_kind = match get_receiver_type(&ctx, &to_extract) {
|
||||
Some(receiver_type) if receiver_type.is_mutable_reference() => RefKind::MutRef,
|
||||
Some(receiver_type) if receiver_type.is_reference() => RefKind::Ref,
|
||||
_ => RefKind::None,
|
||||
let reference_modifier = match get_receiver_type(&ctx, &to_extract) {
|
||||
Some(receiver_type) if receiver_type.is_mutable_reference() => "&mut ",
|
||||
Some(receiver_type) if receiver_type.is_reference() => "&",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
let anchor = Anchor::from(&to_extract)?;
|
||||
@ -83,12 +83,6 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
|
||||
None => to_extract.syntax().text_range(),
|
||||
};
|
||||
|
||||
let reference_modifier = match ref_kind {
|
||||
RefKind::MutRef => "&mut ",
|
||||
RefKind::Ref => "&",
|
||||
RefKind::None => "",
|
||||
};
|
||||
|
||||
match anchor {
|
||||
Anchor::Before(_) | Anchor::Replace(_) => {
|
||||
format_to!(buf, "let {} = {}", var_name, reference_modifier)
|
||||
@ -176,13 +170,6 @@ fn get_receiver(expression: ast::Expr) -> Option<ast::Expr> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum RefKind {
|
||||
Ref,
|
||||
MutRef,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Anchor {
|
||||
Before(SyntaxNode),
|
||||
|
Loading…
Reference in New Issue
Block a user