less wordy ref_kind assignment

This commit is contained in:
Jeroen Vannevel 2022-01-05 21:08:46 +00:00
parent 053ae2452c
commit 2724b35490
No known key found for this signature in database
GPG key ID: 78EF5F52F38C49BD

View file

@ -52,16 +52,10 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option
}
}
let ref_kind: RefKind = if let Some(receiver_type) = get_receiver_type(&ctx, &to_extract) {
if receiver_type.is_mutable_reference() {
RefKind::MutRef
} else if receiver_type.is_reference() {
RefKind::Ref
} else {
RefKind::None
}
} else {
RefKind::None
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 anchor = Anchor::from(&to_extract)?;