Skip to content

Instantly share code, notes, and snippets.

@CarlKCarlK
Created October 19, 2022 21:00
Show Gist options
  • Save CarlKCarlK/c9859baac4a198a7d016f0d9b60c4bd0 to your computer and use it in GitHub Desktop.
Save CarlKCarlK/c9859baac4a198a7d016f0d9b60c4bd0 to your computer and use it in GitHub Desktop.
fn count_statements() {
let mut stmt_counter = StmtCounter { count: 0 };
let item_fn_old: ItemFn = parse_quote! {
fn hello() {
println!("hello world");
{
println!("hello solar system");
println!("hello galaxy");
}
}
};
let item_fn_new = stmt_counter.fold_item_fn(item_fn_old);
println!("item_fn_new: {}", quote!(#item_fn_new));
println!("count: {}", stmt_counter.count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment