mirascript-vm-derive 0.1.105

Derive macros for exposing live Rust values to MiraScript
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use quote::format_ident;
use syn::{Attribute, Ident};

pub fn conditional_attrs(attrs: &[Attribute]) -> Vec<&Attribute> {
    attrs
        .iter()
        .filter(|attr| attr.path().is_ident("cfg") || attr.path().is_ident("cfg_attr"))
        .collect()
}

pub fn rust_name(ident: &Ident) -> String {
    let name = ident.to_string();
    name.strip_prefix("r#").unwrap_or(&name).to_owned()
}

pub fn upper_ident(ident: &Ident) -> Ident {
    format_ident!("{}", rust_name(ident).to_uppercase(), span = ident.span())
}