Introduce pmp-macro-core crate: implement attribute parsing, macro registration, and boilerplate generation for PmpMacro trait.

This commit is contained in:
2026-03-05 08:22:28 +01:00
parent 431fe30e34
commit 36b065ddb2
9 changed files with 271 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
use darling::{ FromMeta };
use darling::FromMeta;
/// Implemented by any item that carries a `Vec<syn::Attribute>`.
///

View File

@@ -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()))
}
}