Add literal matcher

This commit is contained in:
Edwin Cheng 2019-04-19 21:21:47 +08:00
parent 313854c728
commit c5983b85fc
3 changed files with 35 additions and 0 deletions

View file

@ -797,4 +797,16 @@ MACRO_ITEMS@[0; 40)
);
assert_expansion(&rules, r#"foo!{'a}"#, r#"struct Ref < 'a > {s : & 'a str}"#);
}
#[test]
fn test_literal() {
let rules = create_rules(
r#"
macro_rules! foo {
($ type:ty $ lit:literal) => { const VALUE: $ type = $ lit;};
}
"#,
);
assert_expansion(&rules, r#"foo!(u8 0)"#, r#"const VALUE: u8 = 0;"#);
}
}