1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#![cfg_attr(not(feature = "std"), no_std)]
extern crate proc_macro;
#[cfg(not(feature = "std"))]
extern crate no_std_compat as std;
use proc_macro::TokenStream;
use std::collections::HashSet;
use std::prelude::v1::*;
use quote::quote;
#[doc(hidden)]
#[proc_macro]
pub fn charset_string(item: TokenStream) -> TokenStream {
assert!(!item.is_empty(), "Cannot parse empty string as charset");
let chars: HashSet<char> = item.to_string().chars().collect();
let iter = chars.into_iter();
TokenStream::from(quote! {
let slice = &[#(#iter),*];
})
}