use PlistEvent;
use Plist;
use std;
use std::collections::BTreeMap;
pub struct IntoEvents {
pub plist: Plist
}
impl Iterator for IntoEvents {
type Item = PlistEvent;
fn next(&mut self) -> Option<PlistEvent> {
panic!();
}
}
enum PlistFlatMap {
Once(std::iter::Once<PlistEvent>),
Array(PlistArrayFlatMap),
}
impl Iterator for PlistFlatMap {
type Item = PlistEvent;
fn next(&mut self) -> Option<PlistEvent> {
panic!();
}
}
fn plist_dict_flat_map((k, v): (String, Plist)) -> std::iter::Chain<std::iter::Once<PlistEvent>, PlistFlatMap> {
use std::iter::once;
once(PlistEvent::StringValue(k)).chain(plist_flat_map(v))
}
type PlistArrayFlatMap = std::iter::FlatMap<std::vec::IntoIter<Plist>, PlistFlatMap, fn(Plist) -> PlistFlatMap>;
fn plist_array_fn(array: Vec<Plist>) -> PlistFlatMap {
use std::iter::once;
use PlistEvent::*;
use Plist::*;
PlistFlatMap::Array(array.into_iter().flat_map(plist_flat_map))
}
fn plist_flat_map(plist: Plist) -> PlistFlatMap {
use std::iter::once;
use PlistEvent::*;
use Plist::*;
match plist {
Array(array) => {
plist_array_fn(array)
},
Dictionary(dict) => {
panic!();
},
Boolean(value) => PlistFlatMap::Once(once(BooleanValue(value))),
Data(value) => PlistFlatMap::Once(once(DataValue(value))),
Date(value) => PlistFlatMap::Once(once(DateValue(value))),
Real(value) => PlistFlatMap::Once(once(RealValue(value))),
Integer(value) => PlistFlatMap::Once(once(IntegerValue(value))),
String(value) => PlistFlatMap::Once(once(StringValue(value)))
}
}