fix(directory): preserve substitution order (#1782)

This commit is contained in:
David Knaack
2020-10-13 21:06:41 +02:00
committed by GitHub
parent dc8e769bdb
commit 4de9e43cff
5 changed files with 45 additions and 19 deletions
+17
View File
@@ -1,6 +1,7 @@
use crate::configs::StarshipRootConfig;
use crate::utils;
use ansi_term::{Color, Style};
use indexmap::IndexMap;
use std::clone::Clone;
use std::collections::HashMap;
@@ -146,6 +147,22 @@ where
}
}
impl<'a, T, S: ::std::hash::BuildHasher + Default> ModuleConfig<'a> for IndexMap<String, T, S>
where
T: ModuleConfig<'a>,
S: Clone,
{
fn from_config(config: &'a Value) -> Option<Self> {
let mut im = IndexMap::default();
for (x, y) in config.as_table()?.iter() {
im.insert(x.clone(), T::from_config(y)?);
}
Some(im)
}
}
impl<'a, T> ModuleConfig<'a> for Option<T>
where
T: ModuleConfig<'a> + Sized,