e52d47a3b8
10539: Add "generate delegate methods" assist r=Veykril a=yoshuawuyts _Co-authored with `@rylev_.` This patch adds a new assist: "generate delegate method" which creates a method that calls to a method defined on an inner field. Delegation is common when authoring newtypes, and having IDE support for this is the best way we can make this easier to author in Rust, bar adding language-level support for it. Thanks! Closes #5944. ## Example __before__ ```rust struct Age(u8); impl Age { fn age(&self) -> u8 { self.0 } } struct Person { ag$0e: Age, } ``` __after__ ```rust struct Age(u8); impl Age { fn age(&self) -> u8 { self.0 } } struct Person { age: Age, } impl Person { $0fn age(&self) -> u8 { self.age.age() } } ``` Co-authored-by: Ryan Levick <me@ryanlevick.com> Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com> |
||
---|---|---|
.. | ||
base_db | ||
cfg | ||
flycheck | ||
hir | ||
hir_def | ||
hir_expand | ||
hir_ty | ||
ide | ||
ide_assists | ||
ide_completion | ||
ide_db | ||
ide_diagnostics | ||
ide_ssr | ||
limit | ||
mbe | ||
parser | ||
paths | ||
proc_macro_api | ||
proc_macro_srv | ||
proc_macro_test | ||
profile | ||
project_model | ||
rust-analyzer | ||
sourcegen | ||
stdx | ||
syntax | ||
test_utils | ||
text_edit | ||
toolchain | ||
tt | ||
vfs | ||
vfs-notify |