forked from notpeter/playdate-docdef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rs
35 lines (30 loc) · 1.08 KB
/
config.rs
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
use std::{collections::HashMap, fmt};
use lazy_static::lazy_static;
use serde::Deserialize;
static TOML_STR_TYPO: &str = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/Typo.toml"));
static TOML_STR_INVALID: &str =
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/Invalid.toml"));
lazy_static! {
pub static ref TYPO: HashMap<String, TypoReplacement> = match toml::from_str(TOML_STR_TYPO) {
Ok(v) => v,
Err(e) => {
panic!("ERROR: Loading Typo.toml failed. {:?}", e)
}
};
pub static ref INVALID: HashMap<String, String> = match toml::from_str(TOML_STR_INVALID) {
Ok(v) => v,
Err(e) => {
panic!("ERROR: Loading Invalid.toml failed. {:?}", e);
}
};
}
#[derive(Deserialize)]
pub struct TypoReplacement {
pub fname: String,
pub parameters: Vec<String>, // You must include a parameters=[] if there are no params.
}
impl fmt::Display for TypoReplacement {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}({})", self.fname, self.parameters.join(", "))
}
}