Switched from Vectors to HashMaps, need to update docs

This commit is contained in:
Lucien Cartier-Tilet 2020-03-29 18:10:45 +02:00
parent 6be0f7e8f6
commit bae1d86544
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 12 additions and 4 deletions

View File

@ -91,6 +91,7 @@ macro_rules! decode_settings {
};
}
use std::collections::HashMap;
/// Representation of the softwares settings
///
/// This struct represents all the settings the software has to follow
@ -116,7 +117,7 @@ pub struct Settings {
/// phonemes. It is currently not possible to have more than one
/// character to be considered as one sound.
#[serde(default)]
pub categories: Vec<(String, String)>,
pub categories: HashMap<String, String>,
/// Soundchange rules
///
@ -124,7 +125,7 @@ pub struct Settings {
/// a regex to be matched while the second represents the change
/// to be made to the input data.
#[serde(default)]
pub rules: Vec<(Regex, Regex)>,
pub rules: HashMap<Regex, Regex>,
}
/// Representation inside the crate of LangEvolves settings.
@ -148,8 +149,8 @@ impl Settings {
pub fn new() -> Self {
Self {
version: Self::get_ruleset_version(),
categories: Vec::new(),
rules: Vec::new(),
categories: HashMap::new(),
rules: HashMap::new(),
}
}

View File

@ -31,6 +31,13 @@ impl Regex {
}
}
use std::hash::{Hash, Hasher};
impl Hash for Regex {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.as_str().hash(state);
}
}
impl ops::Deref for Regex {
type Target = regex::Regex;
fn deref(&self) -> &regex::Regex {