mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 14:43:58 +00:00
84ef3cfa91
feature: Make generate function assist generate a function as a constructor if the generated function has the name "new" and is an asscociated function. close #17050 This PR makes `generate function assist` generate a function as a constructor if the generated function has the name "new" and is an asscociated function. If the asscociate type is a record struct, it generates the constructor like this. ```rust impl Foo { fn new() -> Self { Self { field_1: todo!(), field_2: todo!() } } } ``` If the asscociate type is a tuple struct, it generates the constructor like this. ```rust impl Foo { fn new() -> Self { Self(todo!(), todo!()) } } ``` If the asscociate type is a unit struct, it generates the constructor like this. ```rust impl Foo { fn new() -> Self { Self } } ``` If the asscociate type is another adt, it generates the constructor like this. ```rust impl Foo { fn new() -> Self { todo!() } } ``` |
||
---|---|---|
.. | ||
semantics | ||
term_search | ||
attrs.rs | ||
db.rs | ||
diagnostics.rs | ||
display.rs | ||
from_id.rs | ||
has_source.rs | ||
lib.rs | ||
semantics.rs | ||
source_analyzer.rs | ||
symbols.rs | ||
term_search.rs |