batched_derive 0.2.11

rust macro util for batching expensive operations
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use syn::{Expr, ExprLit, Lit};

pub fn expr_to_u64(expr: &Expr) -> Option<u64> {
    if let Expr::Lit(ExprLit {
        lit: Lit::Int(lit_int),
        ..
    }) = expr
    {
        lit_int.base10_parse::<u64>().ok()
    } else {
        None
    }
}