From 2b438ed9b53fee5689032f3b5fcdda8d15becd5f Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 22 Jun 2017 14:14:29 -0700 Subject: Add builder API to Config --- src/file/format/toml.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/file/format/toml.rs') diff --git a/src/file/format/toml.rs b/src/file/format/toml.rs index 633f39e..2df1fca 100644 --- a/src/file/format/toml.rs +++ b/src/file/format/toml.rs @@ -4,25 +4,27 @@ use std::collections::{HashMap, BTreeMap}; use std::error::Error; use value::{Value, ValueKind}; -pub fn parse(uri: Option<&String>, text: &str, namespace: Option<&String>) -> Result, Box> { +pub fn parse(uri: Option<&String>, + text: &str, + namespace: Option<&String>) + -> Result, Box> { // Parse a TOML value from the provided text let mut root: toml::Value = toml::from_str(text)?; // Limit to namespace if let Some(namespace) = namespace { root = toml::Value::Table(match root { - toml::Value::Table(ref mut table) => { - if let Some(toml::Value::Table(table)) = table.remove(namespace) { - table - } else { - BTreeMap::new() - } - } + toml::Value::Table(ref mut table) => { + if let Some(toml::Value::Table(table)) = + table.remove(namespace) { + table + } else { + BTreeMap::new() + } + } - _ => { - BTreeMap::new() - } - }); + _ => BTreeMap::new(), + }); } // TODO: Have a proper error fire if the root of a file is ever not a Table -- cgit v1.2.3