Skip to content

Commit bfb6e3f

Browse files
committed
ra_hir: migrate some stuff to matches!()
1 parent a8e5da8 commit bfb6e3f

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

crates/ra_hir/src/code_model.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,30 +1042,18 @@ impl Type {
10421042
}
10431043

10441044
pub fn is_bool(&self) -> bool {
1045-
match &self.ty.value {
1046-
Ty::Apply(a_ty) => match a_ty.ctor {
1047-
TypeCtor::Bool => true,
1048-
_ => false,
1049-
},
1050-
_ => false,
1051-
}
1045+
matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. }))
10521046
}
10531047

10541048
pub fn is_mutable_reference(&self) -> bool {
1055-
match &self.ty.value {
1056-
Ty::Apply(a_ty) => match a_ty.ctor {
1057-
TypeCtor::Ref(Mutability::Mut) => true,
1058-
_ => false,
1059-
},
1060-
_ => false,
1061-
}
1049+
matches!(
1050+
self.ty.value,
1051+
Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(Mutability::Mut), .. })
1052+
)
10621053
}
10631054

10641055
pub fn is_unknown(&self) -> bool {
1065-
match &self.ty.value {
1066-
Ty::Unknown => true,
1067-
_ => false,
1068-
}
1056+
matches!(self.ty.value, Ty::Unknown)
10691057
}
10701058

10711059
/// Checks that particular type `ty` implements `std::future::Future`.

0 commit comments

Comments
 (0)