use helpers::TokenizableError; use quote_data::QuoteIt; use quote::ToTokens; use std::collections::{HashMap, HashSet}; use std::marker::PhantomData; #[derive(QuoteIt)] struct TestUnit; #[derive(QuoteIt)] struct TestTuple(i32, i64, Vec); #[derive(QuoteIt)] #[mod_path = "test"] struct TestStruct where T: 'static, P: ToTokens { basic: i32, vec: Vec, string: String, vec_string: Vec, option_string: Option, option_string_none: Option, result: Result, map: HashMap, hash_set: HashSet, str: &'static str, pair: (String, String), _marker_a: PhantomData, _marker_b: PhantomData

} fn get_result(value: T) -> String { let tokens = quote::quote! { #value }; tokens .to_string() .chars() .filter(|c| !c.is_whitespace()) .collect() } #[test] fn test_unit() { let unit = TestUnit; assert_eq!(get_result(&unit), "TestUnit::new()"); let tuple = TestTuple(1, -1, vec![1, 2, 3]); assert_eq!( get_result(&tuple), "TestTuple::new(1i32,-1i64,vec![1u8,2u8,3u8])" ); } #[test] fn test_struct() { let st = TestStruct { basic: 0, vec: vec![1, 2, 3], string: "iroha".to_string(), vec_string: vec![ "yukino".to_string(), "yui".to_string(), "iroha".to_string(), ], option_string: Some("iroha".to_string()), option_string_none: None, result: Ok("233".to_string()), map: vec![(1, "yukino".to_string()), (2, "yui".to_string())] .into_iter() .collect(), hash_set: vec![ "yukino".to_string(), "yui".to_string(), "iroha".to_string(), ] .into_iter() .collect(), str: "test", pair: ("114".to_string(), "514".to_string()), _marker_a: PhantomData::::default(), _marker_b: PhantomData::::default() }; let _ = quote::quote! {#st}; }