use core::fmt::Debug; use proc_macro2::TokenStream; use serde::{Serialize, Deserialize}; use serde_wrapper::TokenStreamWrapper; mod serde_wrapper; #[derive(Debug, Clone, Serialize, Deserialize)] struct TraitProfile{ //functions: HashMap, functions: Vec, } impl TraitProfile{ pub fn new(streams: Vec) -> Self { let mut inner = vec!(); for stream in streams { inner.push(TokenStreamWrapper::new(stream)); } Self{ functions: inner } } } #[derive(Debug, Clone)] enum DeduplicatedFunctionProfile { Single(String, TokenStreamWrapper), Multiple(Vec, TokenStreamWrapper), } /*impl Evaluator { fn deduplicate_functions(&self) -> Self { let mut self = self.clone(); let mut functions: HashMap; for (t_name, t_profile) in self.traits { for (fun_name, fun_profile) in t_profile.functions { if !functions.contains_key(fun_name) { self.functions.insert(fun_name, DeduplicatedFunctionProfile::Single(t_name, fun_profile)) } else { let other = self.functions.remove(fun_name).unwrap(); let traits: Vec; match other { DeduplicatedFunctionProfile::Single(t, _) => traits = vec!(t), DeduplicatedFunctionProfile::Multiple(ts, _) => traits = ts, } self.functions.insert(fun_name, DeduplicatedFunctionProfile::Multiple(traits, fun_profile)) } } } } } */ #[cfg(test)] mod tests { #[test] fn it_works() { let result = 2 + 2; assert_eq!(result, 4); } }