Skip to content

Commit

Permalink
chore: Expand KV tuple for improved readability
Browse files Browse the repository at this point in the history
Signed-off-by: Brennan Kinney <[email protected]>
  • Loading branch information
polarathene committed Oct 6, 2023
1 parent 27547ad commit db2f74a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/file/format/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ fn from_ini(
) -> Value {
let mut map = Map::<String, Value>::new();

let mut sections: Map<Option<&str>, Table> = data.into_iter().map(|(section, props)| {(
section,
props.iter().map(|(k, v)| {
let mut sections: Map<Option<&str>, Table> = data.into_iter().map(|(section, props)| {
let key = section;
let value = props.iter().map(|(k, v)| {
let key = k.to_owned();
let value = Value::new(uri, ValueKind::String(v.to_owned()));
(key, value)
}).collect()
)}).collect();
}).collect();
(key, value)
}).collect();

// Hoist (optional) sectionless properties to the top-level, alongside sections:
map.extend(sections.remove(&None).unwrap_or_default());
Expand Down

0 comments on commit db2f74a

Please sign in to comment.