6

Feat: extracted method from trait impl is placed in existing impl by TiddoLanger...

 1 year ago
source link: https://github.com/rust-lang/rust-analyzer/pull/12991
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Contributor

@TiddoLangerak TiddoLangerak commented Aug 10, 2022

Before

old.mp4

After

new.mp4

Previously, when triggering a method extraction from within an impl trait block, then this would always create a new impl block for
the struct, even if there already is one. Now, if there is already an existing trait-less impl block, then it'll put the extracted method in there.

Caveats:

  • It currently requires the target impl block to be non-empty. This limitation is because the current architecture takes a node_to_insert_after as reference for where to insert the extracted function. An empty impl block doesn't have such a reference node, since it's empty. It seems that supporting this requires a much larger and more complex change.
  • This is my first contribution in rust, so apologies for any beginner mistakes.
All reactions

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK