aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index be18c845c..6d8444462 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1086,6 +1086,28 @@ impl Type {
1086 matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. })) 1086 matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. }))
1087 } 1087 }
1088 1088
1089 pub fn is_option(&self, db: &dyn HirDatabase) -> bool {
1090 if let Some(adt_ty) = self.as_adt() {
1091 if let Adt::Enum(_) = adt_ty {
1092 if self.display(db).to_string().starts_with("Option<") {
1093 return true;
1094 }
1095 }
1096 }
1097 false
1098 }
1099
1100 pub fn is_result(&self, db: &dyn HirDatabase) -> bool {
1101 if let Some(adt_ty) = self.as_adt() {
1102 if let Adt::Enum(_) = adt_ty {
1103 if self.display(db).to_string().starts_with("Result<") {
1104 return true;
1105 }
1106 }
1107 }
1108 false
1109 }
1110
1089 pub fn is_mutable_reference(&self) -> bool { 1111 pub fn is_mutable_reference(&self) -> bool {
1090 matches!( 1112 matches!(
1091 self.ty.value, 1113 self.ty.value,