2015-02-10 21:52:00 +00:00
|
|
|
#![feature(box_patterns)]
|
2014-05-06 01:56:44 +00:00
|
|
|
|
2013-01-03 22:55:46 +00:00
|
|
|
struct HTMLImageData {
|
2014-05-22 23:57:53 +00:00
|
|
|
image: Option<String>
|
2013-01-03 22:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ElementData {
|
2014-05-06 01:56:44 +00:00
|
|
|
kind: Box<ElementKind>
|
2013-01-03 22:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enum ElementKind {
|
|
|
|
HTMLImageElement(HTMLImageData)
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NodeKind {
|
|
|
|
Element(ElementData)
|
|
|
|
}
|
|
|
|
|
2013-02-23 06:15:11 +00:00
|
|
|
struct NodeData {
|
2014-05-06 01:56:44 +00:00
|
|
|
kind: Box<NodeKind>,
|
2013-02-23 06:15:11 +00:00
|
|
|
}
|
2013-01-03 22:55:46 +00:00
|
|
|
|
|
|
|
fn main() {
|
2013-02-23 00:08:16 +00:00
|
|
|
let mut id = HTMLImageData { image: None };
|
2021-08-25 00:39:40 +00:00
|
|
|
let ed = ElementData { kind: Box::new(ElementKind::HTMLImageElement(id)) };
|
|
|
|
let n = NodeData { kind: Box::new(NodeKind::Element(ed)) };
|
|
|
|
|
2013-02-23 06:15:11 +00:00
|
|
|
// n.b. span could be better
|
2013-01-03 22:55:46 +00:00
|
|
|
match n.kind {
|
2014-11-06 08:05:53 +00: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 22:55:46 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|