Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Approach for removal of comments with syn crate
struct CommentRemove;
impl VisitMut for CommentRemove {
fn visit_attribute_mut(&mut self, node: &mut Attribute) {
// identify comments
if node.path.is_ident("doc") {
println!("{:?}", node.tokens);
println!("{:?}", node.path);
// can you "null" out the Attribute in some way so that the comments are removed when you transform back into Rust text source?
// or is there a different approach?
node = &mut Attribute{
bracket_token: None,
pound_token: None,
style: None,
path: None,
tokens: None,
};
}
visit_mut::visit_attribute_mut(self, node);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.