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
26
27
28
29
30
31
32
33
34
35
36
37
38
use lazy_static;
use ;
use Mutex;
use ;
// 创建一个新的类型别名,用于存储特性和结构的定义
type DefinitionCache = ;
// lazy_static! {
// static ref CACHE: Mutex<DefinitionCache> = Mutex::new(HashMap::new());
// }
use Lazy;
// static CACHE: Lazy<Mutex<DefinitionCache>> = Lazy::new(|| Mutex::new(HashSet::new()));
// use std::cell::RefCell;
// thread_local!(static CACHE: RefCell<DefinitionCache> = RefCell::new(HashMap::new()));
// fn add_string_if_empty(s: String) -> Vec<String> {
// CACHE.with(|data| {
// let mut vec = data.borrow_mut();
// if vec.is_empty() {
// vec.push(s);
// }
// vec.clone()
// })
// }
// // 将特性存储到缓存中
// pub fn cache_trait(name: &Ident, trait_item: &ItemTrait) {
// let mut cache = CACHE.lock().unwrap();
// cache.insert(name.to_string(), Item::Trait(trait_item.clone()));
// }
// // 从缓存中获取特性
// pub fn get_trait(name: &Ident) -> Option<Item> {
// let cache = CACHE.lock().unwrap();
// cache.get(&name.to_string()).cloned()
// }