From 38292ea8cb30fd606357a4c2ad9cf533d0884eb2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jan 2016 08:17:37 +0100 Subject: [PATCH] Dont pass the table to the header object, but generate it in ::new() --- libimagstore/src/header.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libimagstore/src/header.rs b/libimagstore/src/header.rs index 730798d2..2c2ce652 100644 --- a/libimagstore/src/header.rs +++ b/libimagstore/src/header.rs @@ -1,8 +1,12 @@ +use std::collections::BTreeMap; use std::error::Error; use std::result::Result as RResult; use toml::{Table, Value}; +use self::error::ParserErrorKind; +use self::error::ParserError; + pub mod error { use std::fmt::{Debug, Display, Formatter}; use std::fmt; @@ -68,10 +72,6 @@ pub mod error { } - -use self::error::ParserErrorKind; -use self::error::ParserError; - /** * EntryHeader * @@ -92,10 +92,12 @@ impl EntryHeader { /** * Get a new header object with a already-filled toml table + * + * Default header values are inserted into the header object by default. */ - pub fn new(toml: Table) -> EntryHeader { + pub fn new() -> EntryHeader { EntryHeader { - toml: toml, + toml: BTreeMap::new(), } } @@ -113,7 +115,11 @@ impl EntryHeader { parser.parse() .ok_or(ParserError::new(ParserErrorKind::TOMLParserErrors, None)) .and_then(|t| verify_header_consistency(t)) - .map(|t| EntryHeader::new(t)) + .map(|t| { + EntryHeader { + toml: t + } + }) } }