From 24f0cd8293c73b376a5e448dcbadcf189e8698aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Fri, 22 Jan 2021 23:29:51 +0100 Subject: replace_if_let_with_match: don't assume sad pattern --- crates/ide_db/src/ty_filter.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/ide_db') diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index 63a945282..f8406851b 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs @@ -49,6 +49,21 @@ impl TryEnum { } } + pub fn happy_pattern(self) -> ast::Pat { + match self { + TryEnum::Result => make::tuple_struct_pat( + make::path_unqualified(make::path_segment(make::name_ref("Ok"))), + iter::once(make::wildcard_pat().into()), + ) + .into(), + TryEnum::Option => make::tuple_struct_pat( + make::path_unqualified(make::path_segment(make::name_ref("Some"))), + iter::once(make::wildcard_pat().into()), + ) + .into(), + } + } + fn type_name(self) -> &'static str { match self { TryEnum::Result => "Result", -- cgit v1.2.3