这是indexloc提供的服务,不要输入任何密码
Skip to content

Improve trait Visitor #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2020
Merged

Improve trait Visitor #2

merged 1 commit into from
Oct 2, 2020

Conversation

regexident
Copy link
Contributor

If we already use a macro for scaffolding method signatures we might as well use it for scaffolding the corresponding match arms.

Took the opportunity to add the missing node types for completeness while I'm at it, in preparation for a possible extraction into a separate crate (Yes, please! 🙏🏻).

(I used rust-analyzer's /xtask/src/ast_src.rs file to source the node kinds.)

@pksunkara pksunkara merged commit 2f6689b into pksunkara:master Oct 2, 2020
@pksunkara
Copy link
Owner

https://docs.rs/rust-visitor

I will make it more generic and move Semantics out to keep it pure visitor crate.

@regexident regexident deleted the improve-visitor branch October 2, 2020 20:33
@pksunkara
Copy link
Owner

pksunkara commented Oct 2, 2020

On second thought, I don't think any other argument is even needed since this is a trait. All the stuff people might need can be pushed into the type which is implementing this trait.

@regexident What do you think about converting like below?

fn $method(&mut self, _: &ast::$node, _semantics: &Semantics) {}

to

fn $method(&mut self, _: &ast::$node) {}

@regexident
Copy link
Contributor Author

Removing _semantics: &Semantics sounds good to me. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants