mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
ra_hir: migrate some stuff to matches!()
This commit is contained in:
parent
a8e5da8a70
commit
bfb6e3fd83
1 changed files with 6 additions and 18 deletions
|
@ -1042,30 +1042,18 @@ impl Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_bool(&self) -> bool {
|
pub fn is_bool(&self) -> bool {
|
||||||
match &self.ty.value {
|
matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. }))
|
||||||
Ty::Apply(a_ty) => match a_ty.ctor {
|
|
||||||
TypeCtor::Bool => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_mutable_reference(&self) -> bool {
|
pub fn is_mutable_reference(&self) -> bool {
|
||||||
match &self.ty.value {
|
matches!(
|
||||||
Ty::Apply(a_ty) => match a_ty.ctor {
|
self.ty.value,
|
||||||
TypeCtor::Ref(Mutability::Mut) => true,
|
Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(Mutability::Mut), .. })
|
||||||
_ => false,
|
)
|
||||||
},
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unknown(&self) -> bool {
|
pub fn is_unknown(&self) -> bool {
|
||||||
match &self.ty.value {
|
matches!(self.ty.value, Ty::Unknown)
|
||||||
Ty::Unknown => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that particular type `ty` implements `std::future::Future`.
|
/// Checks that particular type `ty` implements `std::future::Future`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue