diff options
author | Benjamin Coenen <[email protected]> | 2020-12-15 20:35:41 +0000 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-12-15 20:35:41 +0000 |
commit | 2c82a1aec71e858040f24d4b39d3937c737f1ef5 (patch) | |
tree | ac749184163370c9e203730ec95f68dff04aaacb /crates | |
parent | 490475ee198f31b1e294bf91518430a93811074d (diff) |
generate default implementation for an enum from an enum variant #6860
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/assists/src/handlers/generate_default_from_enum_variant.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crates/assists/src/handlers/generate_default_from_enum_variant.rs b/crates/assists/src/handlers/generate_default_from_enum_variant.rs index 5f6885710..bcea46735 100644 --- a/crates/assists/src/handlers/generate_default_from_enum_variant.rs +++ b/crates/assists/src/handlers/generate_default_from_enum_variant.rs | |||
@@ -105,7 +105,8 @@ mod tests { | |||
105 | fn test_generate_default_from_variant() { | 105 | fn test_generate_default_from_variant() { |
106 | check_assist( | 106 | check_assist( |
107 | generate_default_from_enum_variant, | 107 | generate_default_from_enum_variant, |
108 | r#"enum Variant { | 108 | r#" |
109 | enum Variant { | ||
109 | Undefined, | 110 | Undefined, |
110 | Minor<|>, | 111 | Minor<|>, |
111 | Major, | 112 | Major, |
@@ -128,7 +129,8 @@ impl Default for Variant { | |||
128 | fn test_generate_default_already_implemented() { | 129 | fn test_generate_default_already_implemented() { |
129 | mark::check!(test_gen_default_impl_already_exists); | 130 | mark::check!(test_gen_default_impl_already_exists); |
130 | check_not_applicable( | 131 | check_not_applicable( |
131 | r#"enum Variant { | 132 | r#" |
133 | enum Variant { | ||
132 | Undefined, | 134 | Undefined, |
133 | Minor<|>, | 135 | Minor<|>, |
134 | Major, | 136 | Major, |
@@ -146,7 +148,8 @@ impl Default for Variant { | |||
146 | fn test_add_from_impl_no_element() { | 148 | fn test_add_from_impl_no_element() { |
147 | mark::check!(test_gen_default_on_non_unit_variant_not_implemented); | 149 | mark::check!(test_gen_default_on_non_unit_variant_not_implemented); |
148 | check_not_applicable( | 150 | check_not_applicable( |
149 | r#"enum Variant { | 151 | r#" |
152 | enum Variant { | ||
150 | Undefined, | 153 | Undefined, |
151 | Minor(u32)<|>, | 154 | Minor(u32)<|>, |
152 | Major, | 155 | Major, |
@@ -159,7 +162,8 @@ impl Default for Variant { | |||
159 | check_assist( | 162 | check_assist( |
160 | generate_default_from_enum_variant, | 163 | generate_default_from_enum_variant, |
161 | r#"enum Variant { Undefi<|>ned }"#, | 164 | r#"enum Variant { Undefi<|>ned }"#, |
162 | r#"enum Variant { Undefined } | 165 | r#" |
166 | enum Variant { Undefined } | ||
163 | 167 | ||
164 | impl Default for Variant { | 168 | impl Default for Variant { |
165 | fn default() -> Self { | 169 | fn default() -> Self { |