From f67586066d5299c11ee69823a6dfd3148eaa5ec7 Mon Sep 17 00:00:00 2001 From: Domantas Jadenkus Date: Sun, 14 Feb 2021 11:09:56 +0200 Subject: rename existing assist to generate_enum_is_method --- crates/ide_assists/src/tests/generated.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index d42875822..44bede0d9 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -483,9 +483,9 @@ struct Point { } #[test] -fn doctest_generate_enum_match_method() { +fn doctest_generate_enum_is_method() { check_doc_test( - "generate_enum_match_method", + "generate_enum_is_method", r#####" enum Version { Undefined, -- cgit v1.2.3 From 2dcd5d7a7c41407478360bb2b77b3bfa857cca09 Mon Sep 17 00:00:00 2001 From: Domantas Jadenkus Date: Sun, 14 Feb 2021 12:06:42 +0200 Subject: add generate_enum_into_method assist --- crates/ide_assists/src/tests/generated.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 44bede0d9..39f48dd76 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -482,6 +482,35 @@ struct Point { ) } +#[test] +fn doctest_generate_enum_into_method() { + check_doc_test( + "generate_enum_into_method", + r#####" +enum Value { + Number(i32), + Text(String)$0, +} +"#####, + r#####" +enum Value { + Number(i32), + Text(String), +} + +impl Value { + fn into_text(self) -> Option { + if let Self::Text(v) = self { + Some(v) + } else { + None + } + } +} +"#####, + ) +} + #[test] fn doctest_generate_enum_is_method() { check_doc_test( -- cgit v1.2.3 From e0f08fcc20ba18a8225b5c591b8b5429090d1943 Mon Sep 17 00:00:00 2001 From: Domantas Jadenkus Date: Sun, 14 Feb 2021 19:26:37 +0200 Subject: add generate_enum_as_method assist --- crates/ide_assists/src/tests/generated.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 39f48dd76..14b372c62 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -482,6 +482,35 @@ struct Point { ) } +#[test] +fn doctest_generate_enum_as_method() { + check_doc_test( + "generate_enum_as_method", + r#####" +enum Value { + Number(i32), + Text(String)$0, +} +"#####, + r#####" +enum Value { + Number(i32), + Text(String), +} + +impl Value { + fn as_text(&self) -> Option<&String> { + if let Self::Text(v) = self { + Some(v) + } else { + None + } + } +} +"#####, + ) +} + #[test] fn doctest_generate_enum_into_method() { check_doc_test( -- cgit v1.2.3 From 558bcf4e0bf9d94ab51238e59f6fc5c170f38c3e Mon Sep 17 00:00:00 2001 From: Domantas Jadenkus Date: Tue, 16 Feb 2021 23:43:21 +0200 Subject: generate try_into instead of into --- crates/ide_assists/src/tests/generated.rs | 58 +++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'crates/ide_assists/src/tests') diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 14b372c62..7f6dbbccf 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -511,35 +511,6 @@ impl Value { ) } -#[test] -fn doctest_generate_enum_into_method() { - check_doc_test( - "generate_enum_into_method", - r#####" -enum Value { - Number(i32), - Text(String)$0, -} -"#####, - r#####" -enum Value { - Number(i32), - Text(String), -} - -impl Value { - fn into_text(self) -> Option { - if let Self::Text(v) = self { - Some(v) - } else { - None - } - } -} -"#####, - ) -} - #[test] fn doctest_generate_enum_is_method() { check_doc_test( @@ -568,6 +539,35 @@ impl Version { ) } +#[test] +fn doctest_generate_enum_try_into_method() { + check_doc_test( + "generate_enum_try_into_method", + r#####" +enum Value { + Number(i32), + Text(String)$0, +} +"#####, + r#####" +enum Value { + Number(i32), + Text(String), +} + +impl Value { + fn try_into_text(self) -> Result { + if let Self::Text(v) = self { + Ok(v) + } else { + Err(self) + } + } +} +"#####, + ) +} + #[test] fn doctest_generate_from_impl_for_enum() { check_doc_test( -- cgit v1.2.3