replace_if_let_with_match: don't assume sad pattern
This commit is contained in:
parent
f301da3c3d
commit
24f0cd8293
2 changed files with 103 additions and 2 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue