From cbc6f94573d7f4601b739e001de5d5f71ec9b552 Mon Sep 17 00:00:00 2001 From: Wesley Norris Date: Sat, 9 Nov 2019 10:56:36 -0500 Subject: Add add_new assist Adds a new assist to autogenerate a new fn based on the selected struct, excluding tuple structs and unions. The fn will inherit the same visibility as the struct and the assist will attempt to reuse any existing impl blocks that exist at the same level of struct. --- crates/ra_assists/src/doc_tests/generated.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/ra_assists/src/doc_tests/generated.rs') diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs index 1bee76f59..176761efb 100644 --- a/crates/ra_assists/src/doc_tests/generated.rs +++ b/crates/ra_assists/src/doc_tests/generated.rs @@ -156,6 +156,28 @@ fn process(map: HashMap) {} ) } +#[test] +fn doctest_add_new() { + check( + "add_new", + r#####" +struct Ctx { + data: T,<|> +} +"#####, + r#####" +struct Ctx { + data: T, +} + +impl Ctx { + fn new(data: T) -> Self { Self { data } } +} + +"#####, + ) +} + #[test] fn doctest_apply_demorgan() { check( -- cgit v1.2.3