mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
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> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |