|
|
@ -32,14 +32,12 @@ fn main() { |
|
|
|
parser.fold(None, {|state:Option<State>, element| { |
|
|
|
parser.fold(None, {|state:Option<State>, element| { |
|
|
|
match element.unwrap() { |
|
|
|
match element.unwrap() { |
|
|
|
Event::ElementStart(tag) => { |
|
|
|
Event::ElementStart(tag) => { |
|
|
|
// println!("Start: {}", tag.name);
|
|
|
|
|
|
|
|
match tag.name.as_ref() { |
|
|
|
match tag.name.as_ref() { |
|
|
|
"title" => Some(State::Title), |
|
|
|
"title" => Some(State::Title), |
|
|
|
_ => None |
|
|
|
_ => None |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
Event::ElementEnd(tag) => { |
|
|
|
Event::ElementEnd(_) => { |
|
|
|
// println!("End: {}", tag.name);
|
|
|
|
|
|
|
|
None // ending a tag always remove the state
|
|
|
|
None // ending a tag always remove the state
|
|
|
|
}, |
|
|
|
}, |
|
|
|
Event::Characters(data) => { |
|
|
|
Event::Characters(data) => { |
|
|
@ -52,8 +50,7 @@ fn main() { |
|
|
|
_ => state |
|
|
|
_ => state |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
Event::CDATA(data) => { |
|
|
|
Event::CDATA(_) => { |
|
|
|
// println!("CDATA: {}", data);
|
|
|
|
|
|
|
|
state |
|
|
|
state |
|
|
|
}, |
|
|
|
}, |
|
|
|
_ => state |
|
|
|
_ => state |
|
|
|