aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-05-07 10:23:38 +0100
committerBenjamin Coenen <[email protected]>2020-05-07 10:23:38 +0100
commit6203e9c4faee288f16d93dbb7dd0f1f8df487d83 (patch)
tree55e64d14c213b74ce32e6db5cc5d84c201b1bf0b /crates/ra_hir/src
parent9cb55966fe0fee791072f275ac55b90b8ee13e32 (diff)
add if let and while let postfix for Option and Result #4348
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-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,