@@ -25,6 +25,7 @@ use crate::{utils::find_struct_impl, AssistContext, AssistId, AssistKind, Assist
25
25
// }
26
26
//
27
27
// impl Version {
28
+ // /// Returns `true` if the version is [`Minor`].
28
29
// fn is_minor(&self) -> bool {
29
30
// matches!(self, Self::Minor)
30
31
// }
@@ -39,6 +40,7 @@ pub(crate) fn generate_enum_match_method(acc: &mut Assists, ctx: &AssistContext)
39
40
return None ;
40
41
}
41
42
43
+ let enum_lowercase_name = to_lower_snake_case ( & parent_enum. name ( ) ?. to_string ( ) ) ;
42
44
let fn_name = to_lower_snake_case ( & variant_name. to_string ( ) ) ;
43
45
44
46
// Return early if we've found an existing new fn
@@ -64,9 +66,12 @@ pub(crate) fn generate_enum_match_method(acc: &mut Assists, ctx: &AssistContext)
64
66
65
67
format_to ! (
66
68
buf,
67
- " {}fn is_{}(&self) -> bool {{
69
+ " /// Returns `true` if the {} is [`{}`].
70
+ {}fn is_{}(&self) -> bool {{
68
71
matches!(self, Self::{})
69
72
}}" ,
73
+ enum_lowercase_name,
74
+ variant_name,
70
75
vis,
71
76
fn_name,
72
77
variant_name
@@ -133,6 +138,7 @@ enum Variant {
133
138
}
134
139
135
140
impl Variant {
141
+ /// Returns `true` if the variant is [`Minor`].
136
142
fn is_minor(&self) -> bool {
137
143
matches!(self, Self::Minor)
138
144
}
@@ -180,6 +186,7 @@ enum Variant {
180
186
enum Variant { Undefined }
181
187
182
188
impl Variant {
189
+ /// Returns `true` if the variant is [`Undefined`].
183
190
fn is_undefined(&self) -> bool {
184
191
matches!(self, Self::Undefined)
185
192
}
@@ -204,6 +211,7 @@ pub(crate) enum Variant {
204
211
}
205
212
206
213
impl Variant {
214
+ /// Returns `true` if the variant is [`Minor`].
207
215
pub(crate) fn is_minor(&self) -> bool {
208
216
matches!(self, Self::Minor)
209
217
}
0 commit comments