Add missing test case for "Convert to named struct" assist

This commit is contained in:
unexge 2021-04-23 16:18:10 +03:00
parent 97270dfb91
commit 5e765895cf

View File

@ -418,6 +418,46 @@ impl Outer {
let Outer(Inner { field1: x }) = self;
x
}
}"#,
);
check_assist(
convert_tuple_struct_to_named_struct,
r#"
struct Inner(u32);
struct Outer$0(Inner);
impl Outer {
fn new() -> Self {
Self(Inner(42))
}
fn into_inner(self) -> u32 {
(self.0).0
}
fn into_inner_destructed(self) -> u32 {
let Outer(Inner(x)) = self;
x
}
}"#,
r#"
struct Inner(u32);
struct Outer { field1: Inner }
impl Outer {
fn new() -> Self {
Self { field1: Inner(42) }
}
fn into_inner(self) -> u32 {
(self.field1).0
}
fn into_inner_destructed(self) -> u32 {
let Outer { field1: Inner(x) } = self;
x
}
}"#,
);
}