diff options
| author | Edward Barnard | 2015-12-25 20:45:06 +0000 |
|---|---|---|
| committer | Edward Barnard | 2015-12-26 19:36:19 +0000 |
| commit | 0ec05856dab205db2a874dc45340f8b522bd7634 (patch) | |
| tree | 708e1a76b5148ffc7813286432ff642ddd8fc3b0 /src/builder.rs | |
| parent | 261510a0c61da1afbbb4c5876023e2210fc60901 (diff) | |
| download | rust-plist-0ec05856dab205db2a874dc45340f8b522bd7634.tar.bz2 | |
Kill StartPlist and EndPlist
Diffstat (limited to 'src/builder.rs')
| -rw-r--r-- | src/builder.rs | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/builder.rs b/src/builder.rs index 6ce78c5..7bb09b9 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -17,15 +17,11 @@ impl<T: Iterator<Item = Result<PlistEvent>>> Builder<T> { pub fn build(mut self) -> Result<Plist> { try!(self.bump()); - if let Some(PlistEvent::StartPlist) = self.token { - try!(self.bump()); - } let plist = try!(self.build_value()); try!(self.bump()); match self.token { None => (), - Some(PlistEvent::EndPlist) => try!(self.bump()), // The stream should have finished _ => return Err(Error::InvalidData), }; @@ -43,9 +39,6 @@ impl<T: Iterator<Item = Result<PlistEvent>>> Builder<T> { fn build_value(&mut self) -> Result<Plist> { match self.token.take() { - Some(PlistEvent::StartPlist) => Err(Error::InvalidData), - Some(PlistEvent::EndPlist) => Err(Error::InvalidData), - Some(PlistEvent::StartArray(len)) => Ok(Plist::Array(try!(self.build_array(len)))), Some(PlistEvent::StartDictionary(len)) => { Ok(Plist::Dictionary(try!(self.build_dict(len)))) @@ -116,23 +109,19 @@ mod tests { // Input - let events = vec![ - StartPlist, - StartDictionary(None), - StringValue("Author".to_owned()), - StringValue("William Shakespeare".to_owned()), - StringValue("Lines".to_owned()), - StartArray(None), - StringValue("It is a tale told by an idiot,".to_owned()), - StringValue("Full of sound and fury, signifying nothing.".to_owned()), - EndArray, - StringValue("Birthdate".to_owned()), - IntegerValue(1564), - StringValue("Height".to_owned()), - RealValue(1.60), - EndDictionary, - EndPlist, - ]; + let events = vec![StartDictionary(None), + StringValue("Author".to_owned()), + StringValue("William Shakespeare".to_owned()), + StringValue("Lines".to_owned()), + StartArray(None), + StringValue("It is a tale told by an idiot,".to_owned()), + StringValue("Full of sound and fury, signifying nothing.".to_owned()), + EndArray, + StringValue("Birthdate".to_owned()), + IntegerValue(1564), + StringValue("Height".to_owned()), + RealValue(1.60), + EndDictionary]; let builder = Builder::new(events.into_iter().map(|e| Ok(e))); let plist = builder.build(); |
