Introduce pmp-macro-core crate: implement attribute parsing, macro registration, and boilerplate generation for PmpMacro trait.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use darling::{ FromMeta };
|
||||
use darling::FromMeta;
|
||||
|
||||
/// Implemented by any item that carries a `Vec<syn::Attribute>`.
|
||||
///
|
||||
|
||||
@@ -65,3 +65,21 @@ impl FromMeta for StrictPath
|
||||
Path::from_expr(expr).map(StrictPath)
|
||||
}
|
||||
}
|
||||
|
||||
/// A Rust expression that must be written as `= <expr>`
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StrictExpr(pub syn::Expr);
|
||||
|
||||
impl FromMeta for StrictExpr
|
||||
{
|
||||
fn from_word() -> Result<Self>
|
||||
{
|
||||
Err(Error::custom(
|
||||
"expected `= <expr>`, provide an expression, e.g. `target = Target::CLASS | Target::INTERFACE`"
|
||||
))
|
||||
}
|
||||
|
||||
fn from_expr(expr: &syn::Expr) -> Result<Self> {
|
||||
Ok(StrictExpr(expr.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user