Dont pass the table to the header object, but generate it in ::new()

This commit is contained in:
Matthias Beyer 2016-01-22 08:17:37 +01:00
parent 51c0a4cf50
commit 38292ea8cb

View file

@ -1,8 +1,12 @@
use std::collections::BTreeMap;
use std::error::Error; use std::error::Error;
use std::result::Result as RResult; use std::result::Result as RResult;
use toml::{Table, Value}; use toml::{Table, Value};
use self::error::ParserErrorKind;
use self::error::ParserError;
pub mod error { pub mod error {
use std::fmt::{Debug, Display, Formatter}; use std::fmt::{Debug, Display, Formatter};
use std::fmt; use std::fmt;
@ -68,10 +72,6 @@ pub mod error {
} }
use self::error::ParserErrorKind;
use self::error::ParserError;
/** /**
* EntryHeader * EntryHeader
* *
@ -92,10 +92,12 @@ impl EntryHeader {
/** /**
* Get a new header object with a already-filled toml table * 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 { EntryHeader {
toml: toml, toml: BTreeMap::new(),
} }
} }
@ -113,7 +115,11 @@ impl EntryHeader {
parser.parse() parser.parse()
.ok_or(ParserError::new(ParserErrorKind::TOMLParserErrors, None)) .ok_or(ParserError::new(ParserErrorKind::TOMLParserErrors, None))
.and_then(|t| verify_header_consistency(t)) .and_then(|t| verify_header_consistency(t))
.map(|t| EntryHeader::new(t)) .map(|t| {
EntryHeader {
toml: t
}
})
} }
} }