mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 09:13:39 +01:00
MappingDefModel::into_mapping_list
returns MappingList
This commit is contained in:
parent
d1bc0ef0d4
commit
97780f987e
@ -42,8 +42,9 @@ struct MappingDefModel {
|
|||||||
mappings: IndexMap<MappingTarget, Vec<String>>,
|
mappings: IndexMap<MappingTarget, Vec<String>>,
|
||||||
}
|
}
|
||||||
impl MappingDefModel {
|
impl MappingDefModel {
|
||||||
fn into_mapping_list(self) -> Vec<(String, MappingTarget)> {
|
fn into_mapping_list(self) -> MappingList {
|
||||||
self.mappings
|
let list = self
|
||||||
|
.mappings
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|(target, matcher)| {
|
.flat_map(|(target, matcher)| {
|
||||||
matcher
|
matcher
|
||||||
@ -51,7 +52,8 @@ impl MappingDefModel {
|
|||||||
.map(|rule| (rule, target.clone()))
|
.map(|rule| (rule, target.clone()))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
.collect()
|
.collect();
|
||||||
|
MappingList(list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ fn read_all_mappings() -> anyhow::Result<MappingList> {
|
|||||||
{
|
{
|
||||||
let toml_string = fs::read_to_string(entry.path())?;
|
let toml_string = fs::read_to_string(entry.path())?;
|
||||||
let mappings = toml::from_str::<MappingDefModel>(&toml_string)?.into_mapping_list();
|
let mappings = toml::from_str::<MappingDefModel>(&toml_string)?.into_mapping_list();
|
||||||
all_mappings.extend(mappings);
|
all_mappings.extend(mappings.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(MappingList(all_mappings))
|
Ok(MappingList(all_mappings))
|
||||||
|
Loading…
Reference in New Issue
Block a user