1use std::fmt;
10
11use xmlparser::{
12 FromSpan,
13 Stream,
14 StrSpan,
15};
16
17use error::{
18 StreamResult,
19};
20use {
21 Length,
22 StreamExt,
23};
24
25#[derive(Copy, Clone, PartialEq)]
29pub struct NumberList<'a>(Stream<'a>);
30
31impl<'a> FromSpan<'a> for NumberList<'a> {
32 fn from_span(span: StrSpan<'a>) -> Self {
33 NumberList(Stream::from_span(span))
34 }
35}
36
37impl<'a> fmt::Debug for NumberList<'a> {
38 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
39 write!(f, "NumberList({:?})", self.0.span())
40 }
41}
42
43impl<'a> Iterator for NumberList<'a> {
44 type Item = StreamResult<f64>;
45
46 fn next(&mut self) -> Option<Self::Item> {
47 if self.0.at_end() {
48 None
49 } else {
50 Some(self.0.parse_list_number())
51 }
52 }
53}
54
55#[derive(Copy, Clone, PartialEq)]
59pub struct LengthList<'a>(Stream<'a>);
60
61impl<'a> LengthList<'a> {
62 pub fn from_span(span: StrSpan<'a>) -> LengthList<'a> {
64 LengthList(Stream::from_span(span))
65 }
66}
67
68impl<'a> fmt::Debug for LengthList<'a> {
69 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
70 write!(f, "LengthList({:?})", self.0.span())
71 }
72}
73
74impl<'a> Iterator for LengthList<'a> {
75 type Item = StreamResult<Length>;
76
77 fn next(&mut self) -> Option<Self::Item> {
78 if self.0.at_end() {
79 None
80 } else {
81 Some(self.0.parse_list_length())
82 }
83 }
84}