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