socket_addr_macros 1.0.1

Check and parse SocketAddr at compile-time
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use proc_macro2::TokenStream;
use quote::quote;

pub trait ResultErrAsCompileErrorExt<E: ToString> {
    fn err_as_compile_error(self) -> TokenStream;
}

impl<E: ToString> ResultErrAsCompileErrorExt<E> for Result<TokenStream, E> {
    fn err_as_compile_error(self) -> TokenStream {
        self.unwrap_or_else(|err| {
            let err = err.to_string();
            quote! {
                compile_error!(#err);
            }
        })
    }
}