rustbasic-macro 0.0.10

Rust Basic : Planned Development
Documentation
// 이 소스코드에 사용된 모든 라이브러리 제작자들에게 감사합니다.
// Thanks to the creators of all the libraries used in this source code.
// Thanks to all library authors used in this source code.
이 프로그램에 사용된 모든 라이브러리 제작자에게 감사합니다.

pub struct MetaNameValue {
    pub path: Path,
    pub eq_token: Token![=],
    pub value: Expr,
}

pub enum Expr {
    /// A slice literal expression: `[a, b, c, d]`.
    Array(ExprArray),

    /// An async block: `async { ... }`.
    Async(ExprAsync),

    /// An await expression: `fut.await`.
    Await(ExprAwait),

    /// An `if` expression with an optional `else` block: `if expr { ... }
    /// else { ... }`.
    ///
    /// The `else` branch expression may only be an `If` or `Block`
    /// expression, not any of the other types of expression.
    If(ExprIf),

    /// A `let` guard: `let Some(x) = opt`.
    Let(ExprLet),

    /// A literal in place of an expression: `1`, `"foo"`.
    Lit(ExprLit),

    /// Conditionless loop: `loop { ... }`.
    Loop(ExprLoop),

    /// A macro invocation expression: `format!("{}", q)`.
    Macro(ExprMacro),

    /// A `match` expression: `match n { Some(n) => {}, None => {} }`.
    Match(ExprMatch),
    /// A path like `std::mem::replace` possibly containing generic
    /// parameters and a qualified self-type.
    ///
    /// A plain identifier like `x` is a path of length 1.
    Path(ExprPath),
    /// A `return`, with an optional value to be returned.
    Return(ExprReturn),

    /// A struct literal expression: `Point { x: 1, y: 1 }`.
    ///
    /// The `rest` provides the value of the remaining fields as in `S { a:
    /// 1, b: 1, ..rest }`.
    Struct(ExprStruct),
    /// An unsafe block: `unsafe { ... }`.
    Unsafe(ExprUnsafe),

    /// Tokens in expression position not interpreted by Syn.
    Verbatim(TokenStream),

    /// A while loop: `while expr { ... }`.
    While(ExprWhile),

    // For testing exhaustiveness in downstream code, use the following idiom:
    //
    //     match expr {
    //         Expr::Array(expr) => {...}
    //         Expr::Assign(expr) => {...}
    //         ...
    //         Expr::Yield(expr) => {...}
    //
    //         #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))]
    //         _ => { /* some sane fallback */ }
    //     }
    //
    // This way we fail your tests but don't break your library when adding
    // a variant. You will be notified by a test failure when a variant is
    // added, so that you can add code to handle it, but your library will
    // continue to compile and work for downstream users in the interim.
}

----------------------------------------------------

let name_value: syn::MetaNameValue = input.parse()?;

    match &name_value.value.Lit(ExprLit) {
        syn::Lit::Int(expr) => {
            if threads.is_some() {
                return Err(syn::Error::new_spanned(
                    name_value,
                    "multiple threads argments",
                ));
            }

            let num = expr.base10_parse::<std::num::NonZeroU32>()?;
            threads = Some((num.get(), expr.span()));
        }
        _ => {
        }
    }





    match &*ident.to_string().to_lowercase() {
        "threads" => match &name_value.value {
//                    syn::Expr::Lit(syn::ExprLit { lit, .. }) => {
            syn::Expr::Lit (lit) => {
//                        match lit {
                    syn::Lit::Int(expr) => {
                        if threads.is_some() {
                            return Err(syn::Error::new_spanned(
                                name_value,
                                "multiple threads argments",
                            ));
                        }
                    
                        let num = expr.base10_parse::<std::num::NonZeroU32>()?;
                        threads = Some((num.get(), expr.span()));
                    },
                    _ => {
                        return Err(syn::Error::new_spanned(
                            name_value,
                            "threads argument must be an integer",
                        ))
//                            }
                }
            }
        },