Update src/config.rs

Co-authored-by: Eric Huss <eric@huss.org>
This commit is contained in:
toyboot4e 2020-05-08 19:56:41 +09:00 committed by GitHub
parent 2f59dbf1ef
commit 282e55122e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 7 deletions

View File

@ -145,14 +145,9 @@ impl Config {
if key == "book" || key == "build" { if key == "book" || key == "build" {
if let serde_json::Value::Object(ref map) = parsed_value { if let serde_json::Value::Object(ref map) = parsed_value {
// To `set` each `key`, we wrap them as `prefix.key` // To `set` each `key`, we wrap them as `prefix.key`
let prefix = &key; // "book" or "build"
let mut s = String::new();
for (k, v) in map { for (k, v) in map {
s.clear(); let full_key = format!("{}.{}", key, k);
s.push_str(prefix); self.set(&full_key, v).expect("unreachable");
s.push('.');
s.push_str(k);
self.set(&s, v).expect("unreachable");
} }
return; return;
} }