mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-28 00:00:03 +00:00
Add new crate leon-macros
that provide template!
with identical syntax as runtime parsing (#946)
`leon_macros::template!` can parse template at compile-time. It accepts a utf-8 string literal and uses `leon` internally to parse it, then generate code that evaluates to `Template<'static>`. - Exclude fuzz from crate leon when publishing - Impl fn-like proc-macro `leon_macros::template!` - Add dep `leon-macros` to binstalk - Use `leon_macros::template!` in `binstalk::fetchers::gh_crate_meta::hosting` - Add doc for `leon-macros` in `leon` - Improve `std::fmt::Display` impl for `leon::ParseError` - Fixed broken infra link in leon Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
fa0455a417
commit
5683ca2476
18 changed files with 373 additions and 91 deletions
21
crates/leon-macros/tests/parsing.rs
Normal file
21
crates/leon-macros/tests/parsing.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
use leon::{Item, Template};
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
assert_eq!(leon_macros::template!(""), Template::new(&[], None),);
|
||||
|
||||
assert_eq!(
|
||||
leon_macros::template!("a"),
|
||||
Template::new(&[Item::Text("a")], None),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
leon_macros::template!("{1}"),
|
||||
Template::new(&[Item::Key("1")], None),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
leon_macros::template!("a{ 1 } c"),
|
||||
Template::new(&[Item::Text("a"), Item::Key("1"), Item::Text(" c")], None),
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue