2015-02-10 15:52:00 -06:00
|
|
|
#![feature(box_patterns)]
|
2014-05-05 20:56:44 -05:00
|
|
|
|
2013-01-03 16:55:46 -06:00
|
|
|
struct HTMLImageData {
|
2014-05-22 18:57:53 -05:00
|
|
|
image: Option<String>
|
2013-01-03 16:55:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ElementData {
|
2014-05-05 20:56:44 -05:00
|
|
|
kind: Box<ElementKind>
|
2013-01-03 16:55:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
enum ElementKind {
|
|
|
|
HTMLImageElement(HTMLImageData)
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NodeKind {
|
|
|
|
Element(ElementData)
|
|
|
|
}
|
|
|
|
|
2013-02-23 00:15:11 -06:00
|
|
|
struct NodeData {
|
2014-05-05 20:56:44 -05:00
|
|
|
kind: Box<NodeKind>,
|
2013-02-23 00:15:11 -06:00
|
|
|
}
|
2013-01-03 16:55:46 -06:00
|
|
|
|
|
|
|
fn main() {
|
2013-02-22 18:08:16 -06:00
|
|
|
let mut id = HTMLImageData { image: None };
|
2021-08-24 19:39:40 -05:00
|
|
|
let ed = ElementData { kind: Box::new(ElementKind::HTMLImageElement(id)) };
|
|
|
|
let n = NodeData { kind: Box::new(NodeKind::Element(ed)) };
|
|
|
|
|
2013-02-23 00:15:11 -06:00
|
|
|
// n.b. span could be better
|
2013-01-03 16:55:46 -06:00
|
|
|
match n.kind {
|
2014-11-06 02:05:53 -06:00
|
|
|
box NodeKind::Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns
|
|
|
|
box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true }
|
2013-01-03 16:55:46 -06:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|