matched_enums_macro 1.3.0

Contains the macro for matchable enums.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use syn::{spanned::Spanned, Expr, Type, TypePath};

pub fn try_convert_type_expr_into_type(expr: &Expr) -> syn::Result<Type> {
    match &expr {
        Expr::Path(path) => Ok(Type::Path(TypePath {
            qself: path.qself.clone(),
            path: path.path.clone(),
        })),

        _ => Err(syn::Error::new(
            expr.span(),
            "Invallid type expression provided.",
        )),
    }
}