aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-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 5f480c304..7e840add5 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -1083,6 +1083,28 @@ impl Type {
1083 matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. })) 1083 matches!(self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::Bool, .. }))
1084 } 1084 }
1085 1085
1086 pub fn is_option(&self, db: &dyn HirDatabase) -> bool {
1087 if let Some(adt_ty) = self.as_adt() {
1088 if let Adt::Enum(_) = adt_ty {
1089 if self.display(db).to_string().starts_with("Option<") {
1090 return true;
1091 }
1092 }
1093 }
1094 false
1095 }
1096
1097 pub fn is_result(&self, db: &dyn HirDatabase) -> bool {
1098 if let Some(adt_ty) = self.as_adt() {
1099 if let Adt::Enum(_) = adt_ty {
1100 if self.display(db).to_string().starts_with("Result<") {
1101 return true;
1102 }
1103 }
1104 }
1105 false
1106 }
1107
1086 pub fn is_mutable_reference(&self) -> bool { 1108 pub fn is_mutable_reference(&self) -> bool {
1087 matches!( 1109 matches!(
1088 self.ty.value, 1110 self.ty.value,