Skip to content

Commit 3cfa159

Browse files
committed
Add helper functions for working with the global
This also helps to fix a bug I ran into with Rust. rust-lang/rust#37612
1 parent 05a652c commit 3cfa159

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

string-interner/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ use std::sync::Mutex;
88
/// Global interner
99
pub static INTERNER: SyncLazy<Mutex<StringInterner>> = SyncLazy::new(|| Mutex::new(StringInterner::new()));
1010

11+
#[inline]
12+
pub fn get_symbol(value: String) -> Symbol {
13+
INTERNER.lock().unwrap().get_symbol(value)
14+
}
15+
16+
#[inline]
17+
pub fn get_value(s: Symbol) -> Option<String> {
18+
INTERNER.lock().unwrap().get_value(s)
19+
}
20+
1121
pub struct StringInterner {
1222
symbol_map: HashMap<String, usize>,
1323
symbols: Vec<String>,

0 commit comments

Comments
 (0)