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
39
40
41
42
43
44
45
46
47
#[macro_use]
extern crate log;
#[cfg(test)]
extern crate env_logger;
extern crate union_find;
extern crate gluon_base as base;
pub mod typecheck;
pub mod unify_type;
pub mod unify;
pub mod kindcheck;
mod substitution;
mod rename;
pub mod completion;
pub mod metadata;
#[cfg(test)]
mod tests {
use std::cell::RefCell;
use std::rc::Rc;
use base::symbol::{Symbols, SymbolModule, Symbol};
pub fn get_local_interner() -> Rc<RefCell<Symbols>> {
thread_local!(static INTERNER: Rc<RefCell<Symbols>>
= Rc::new(RefCell::new(Symbols::new())));
INTERNER.with(|interner| interner.clone())
}
pub fn intern(s: &str) -> Symbol {
let i = get_local_interner();
let mut i = i.borrow_mut();
if s.chars().next().map(|c| c.is_lowercase()).unwrap_or(false) {
i.symbol(s)
} else {
SymbolModule::new("test".into(), &mut i).scoped_symbol(s)
}
}
}