# lib.rs - source
Source of the Rust file `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/derive-error-0.0.5/src/lib.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    //! Derive custom errors using macros 1.1

    extern crate proc_macro;
    extern crate syn;
    #[macro_use]
    extern crate quote;
    extern crate case;

    mod error;

    use error::Error;
    use proc_macro::TokenStream;

    #[proc_macro_derive(Error, attributes(error))]
    pub fn derive_error(input: TokenStream) -> TokenStream {
        let source = input.to_string();
        let ast = syn::parse_macro_input(&source).expect("failed to parse the error defination");
        Error::new(ast)
            .derive()
            .parse()
            .expect("failed to parse the derived output")
    }