blob: 0be0ce8971aa4d317f15c8f93c90b08208f24428 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
use crate::Tendril;
use once_cell::sync::Lazy;
use std::{collections::HashMap, sync::RwLock};
// TODO: could be an instance on Editor
static REGISTRY: Lazy<RwLock<HashMap<char, Vec<String>>>> =
Lazy::new(|| RwLock::new(HashMap::new()));
pub fn get(register: char) -> Option<Vec<String>> {
let registry = REGISTRY.read().unwrap();
// TODO: no cloning
registry.get(®ister).cloned()
}
// restoring: bool
pub fn set(register: char, values: Vec<String>) {
let mut registry = REGISTRY.write().unwrap();
registry.insert(register, values);
}
|