Skip to content

Instantly share code, notes, and snippets.

@kemurphy
Last active December 20, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemurphy/6093683 to your computer and use it in GitHub Desktop.
Save kemurphy/6093683 to your computer and use it in GitHub Desktop.
let replace_id = @mut None;
let rewriter = @fold::AstFoldFns {
fold_expr: do fold::wrap |e, fld| {
match fold_expr(e, fld, self.def_map, replace_id) {
Some(f) => {
debug!("Rewriting: wrote expr_struct");
f
}
None => fold::noop_fold_expr(e, fld)
}
},
new_id: |id| replace_id.get_or_default(id),
.. *fold::default_ast_fold()
};
let mut replace_id = None;
let rewriter = @fold::AstFoldFns {
fold_expr: do fold::wrap |e, fld| {
match fold_expr(e, fld, self.def_map, &mut replace_id) {
Some(f) => {
debug!("Rewriting: wrote expr_struct");
f
}
None => fold::noop_fold_expr(e, fld)
}
},
new_id: |id| replace_id.get_or_default(id),
.. *fold::default_ast_fold()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment