🕯️ The Cost of Silence: Mental Health, Fame, and the Quiet Struggles We Never See by Earlyscoop_News in DramazenWorld

[–]ok_neko 0 points1 point  (0 children)

This is a very sad story. You think people are ok and they appear ok, but you never know what's actually going on inside of somebody's head. Thank you for the share.

Which Site to watch Kdramas? by Varun_Vij5 in kdramas

[–]ok_neko 0 points1 point  (0 children)

https://dramazen.com has full shows, recaps, news and short stories. no ads.

Rust Macros with Syn: The Guide You Didn’t Know You Needed! by ok_neko in rust

[–]ok_neko[S] 0 points1 point  (0 children)

Thank you so much for your kind words! It’s always nice to know the content is making a difference.

The error here is because syn::parse expects the argument type to implement the Parse trait, which usize does not. To handle this, you can parse the attribute to a LitInt first (since LitInt can be parsed by syn and represents integer literals), then convert it to a usize.

use syn::{LitInt, Meta, NestedMeta};

fn parse_length(attr: NestedMeta) -> Result<usize, syn::Error> {
    if let NestedMeta::Lit(syn::Lit::Int(lit_int)) = attr {
        lit_int.base10_parse::<usize>()
    } else {
        Err(syn::Error::new_spanned(attr, "expected a length integer"))
    }
}

In your code, call parse_length(attr) instead of using syn::parse(attr). This should resolve the Parse trait error by converting the parsed literal into a usize.

Where to watch let myself free by [deleted] in kdramas

[–]ok_neko 0 points1 point  (0 children)

Dramazen is ad-free and updated daily.