diff options
author | David Knaack <davidkna@users.noreply.github.com> | 2020-10-13 21:06:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 15:06:41 -0400 |
commit | 4de9e43cff46c834bd340d24a02fc95d85310a33 (patch) | |
tree | c74b381b14738aaa3416dab46d9f14e22d392a3d /src/config.rs | |
parent | dc8e769bdb6eba58a3a32be054d8c038ba8dd9f6 (diff) |
fix(directory): preserve substitution order (#1782)
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index c781e9035..cc3beaa5a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, |