dash_conversion 0.1.0

Stringify identifier replacing '_'s with '-'s. proc-macro for `treest`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
extern crate proc_macro;
use proc_macro::{TokenStream, TokenTree, Literal};

#[proc_macro]
pub fn dash_conversion(input: TokenStream) -> TokenStream {
    match input.into_iter().next() {
        Some(TokenTree::Ident(name)) => {
            Into::<TokenTree>::into(Literal::string(&name.to_string().replace("_", "-"))).into()
        }
        got => panic!("expected ident; got: {got:?}"),
    }
}