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 {
|
2023-06-22 01:52:31 -04:00
|
|
|
image: Option<String>,
|
2013-01-03 14:55:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ElementData {
|
2023-06-22 01:52:31 -04:00
|
|
|
kind: Box<ElementKind>,
|
2013-01-03 14:55:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum ElementKind {
|
2023-06-22 01:52:31 -04:00
|
|
|
HTMLImageElement(HTMLImageData),
|
2013-01-03 14:55:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum NodeKind {
|
2023-06-22 01:52:31 -04:00
|
|
|
Element(ElementData),
|
2013-01-03 14:55:46 -08:00
|
|
|
}
|
|
|
|
|
|
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)) };
|
|
|
|
|
|
2023-06-28 01:49:12 -04:00
|
|
|
// n.b. span could be better
|
2013-01-03 14:55:46 -08:00
|
|
|
match n.kind {
|
2023-06-22 01:52:31 -04:00
|
|
|
box NodeKind::Element(ed) => match ed.kind {
|
|
|
|
|
//~^ ERROR non-exhaustive patterns
|
|
|
|
|
//~| NOTE the matched value is of type
|
|
|
|
|
//~| NOTE match arms with guards don't count towards exhaustivity
|
2023-10-15 17:36:36 +02:00
|
|
|
//~| NOTE pattern `box ElementKind::HTMLImageElement(_)` not covered
|
2023-06-22 01:52:31 -04:00
|
|
|
//~| NOTE `Box<ElementKind>` defined here
|
|
|
|
|
box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => true,
|
2013-01-03 14:55:46 -08:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|