diff --git a/src/lib.rs b/src/lib.rs index 5068e30..a8791e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -261,12 +261,13 @@ impl IdentifierReplace<'_> { impl VisitMut for IdentifierReplace<'_> { fn visit_expr_mut(&mut self, expr: &mut Expr) { - println!("{:?}", expr); + // println!("{:?}", expr); if let Expr::Path(ExprPath { path, .. }) = expr { println!("match!!! {:?}", path); if path.is_ident(self.identifier_name) { - *expr = parse_quote!(#(self.substitution)); + let num = self.substitution; + *expr = parse_quote!(#num); return; } // This is unfortunately not permitted: diff --git a/tests/repeat_n.rs b/tests/repeat_n.rs index 56120c5..96edb64 100644 --- a/tests/repeat_n.rs +++ b/tests/repeat_n.rs @@ -13,13 +13,18 @@ mod tests { #[allow(unused)] struct Bar; - // #[test] - // fn test() { - // repeat_with_n!(10, n, { impl Foo for Bar<{n as usize}> {} }); - // } + #[test] + fn test() { + repeat_with_n!(10, n, { impl Foo for Bar<{n as usize}> {} }); + } #[test] fn with_macro() { repeat_with_n!(10, longer_identifier, { println!("{}", longer_identifier); }); } + + #[test] + fn nested_macro() { + repeat_with_n!(10, y, { println!("{}", format!("{}", format!("{}{}{}{}", y, y, y, y))); }); + } }