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