Skip to content

Commit 9e417f1

Browse files
committed
[chore] clippy
1 parent b000d6f commit 9e417f1

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/log.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,14 @@ fn flatten_json(log_entry: &Map<String, Value>, prefix: &str) -> BTreeMap<String
117117
match array_value {
118118
Value::Array(array_values) => {
119119
flatten_array(&key, prefix, array_values, &mut flattened_json);
120-
},
120+
}
121121
Value::Object(nested_entry) => {
122122
flattened_json.extend(flatten_json(nested_entry, &format!("{}{} > ", prefix, key)));
123-
},
123+
}
124124
_ => {
125-
flattened_json.insert(format!("{}{}", prefix, key),array_value.to_string());
126-
},
125+
flattened_json.insert(format!("{}{}", prefix, key), array_value.to_string());
126+
}
127127
};
128-
129128
}
130129
}
131130
Value::Object(nested_entry) => {
@@ -138,22 +137,19 @@ fn flatten_json(log_entry: &Map<String, Value>, prefix: &str) -> BTreeMap<String
138137
}
139138

140139
fn flatten_array(key: &str, prefix: &str, array_values: &[Value], flattened_json: &mut BTreeMap<String, String>) {
141-
for (index, array_value) in array_values.iter().enumerate() {
142-
let key = format!("{}[{}]", key, index + 1); // lua tables indexes start with 1
143-
144-
match array_value {
145-
Value::Array(nested_array_values) => {
146-
flatten_array(&key, prefix, nested_array_values, flattened_json)
147-
},
148-
Value::Object(nested_entry) => {
149-
flattened_json.extend(flatten_json(nested_entry, &format!("{}{} > ", prefix, key)));
150-
},
151-
_ => {
152-
flattened_json.insert(format!("{}{}", prefix, key),array_value.to_string());
153-
},
154-
};
140+
for (index, array_value) in array_values.iter().enumerate() {
141+
let key = format!("{}[{}]", key, index + 1); // lua tables indexes start with 1
155142

156-
}
143+
match array_value {
144+
Value::Array(nested_array_values) => flatten_array(&key, prefix, nested_array_values, flattened_json),
145+
Value::Object(nested_entry) => {
146+
flattened_json.extend(flatten_json(nested_entry, &format!("{}{} > ", prefix, key)));
147+
}
148+
_ => {
149+
flattened_json.insert(format!("{}{}", prefix, key), array_value.to_string());
150+
}
151+
};
152+
}
157153
}
158154

159155
fn get_string_value(value: &BTreeMap<String, String>, keys: &[String]) -> Option<String> {
@@ -168,7 +164,10 @@ fn get_string_value_or_default(value: &BTreeMap<String, String>, keys: &[String]
168164

169165
fn write_additional_values(out: &mut dyn Write, log_entry: &BTreeMap<String, String>, additional_values: &[String], handlebars: &Handlebars<'static>) {
170166
for additional_value_prefix in additional_values {
171-
for additional_value in log_entry.keys().filter(|k| k.to_owned() == additional_value_prefix || k.to_owned().starts_with(&format!("{}{}", additional_value_prefix, " > "))) {
167+
for additional_value in log_entry
168+
.keys()
169+
.filter(|k| *k == additional_value_prefix || k.starts_with(&format!("{}{}", additional_value_prefix, " > ")))
170+
{
172171
if let Some(value) = get_string_value(log_entry, &[additional_value.to_string()]) {
173172
let mut variables: BTreeMap<String, String> = BTreeMap::new();
174173
variables.insert("key".to_string(), additional_value.to_string());

0 commit comments

Comments
 (0)