mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-02 18:20: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
|
@ -121,12 +121,21 @@
|
|||
//! assert_eq!(template.render(&values).unwrap().as_str(), "hello pontifex");
|
||||
//! ```
|
||||
//!
|
||||
//! # Compile-time parsing
|
||||
//!
|
||||
//! You can either use [`leon-macros`](https://docs.rs/leon-macros)'s
|
||||
//! [`template!`](https://docs.rs/leon-macros/latest/leon_macros/macro.template.html),
|
||||
//! a proc-macro, with the exact same syntax as the normal parser, or this
|
||||
//! crate's [`template!`] rules-macro, which requires a slightly different
|
||||
//! syntax but doesn't bring in additional dependencies. In either case,
|
||||
//! the leon library is required as a runtime dependency.
|
||||
//!
|
||||
//! # Errors
|
||||
//!
|
||||
//! Leon will return a [`LeonError::InvalidTemplate`] if the template fails to
|
||||
//! Leon will return a [`ParseError`] if the template fails to
|
||||
//! parse. This can happen if there are unbalanced braces, or if a key is empty.
|
||||
//!
|
||||
//! Leon will return a [`LeonError::MissingKey`] if a key is missing from keyed
|
||||
//! Leon will return a [`RenderError::MissingKey`] if a key is missing from keyed
|
||||
//! values passed to [`Template::render()`], unless a default value is provided
|
||||
//! with [`Template.default`].
|
||||
//!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue