2019-06-12 18:18:32 +03:00
|
|
|
//@ check-pass
|
|
|
|
|
2017-06-18 18:18:08 +02:00
|
|
|
struct Attr {
|
|
|
|
name: String,
|
|
|
|
value: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Element {
|
|
|
|
attrs: Vec<Box<Attr>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Element {
|
|
|
|
pub unsafe fn get_attr<'a>(&'a self, name: &str) {
|
|
|
|
self.attrs
|
|
|
|
.iter()
|
|
|
|
.find(|attr| {
|
|
|
|
let attr: &&Box<Attr> = std::mem::transmute(attr);
|
|
|
|
true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-31 13:08:01 +01:00
|
|
|
fn main() {
|
2017-06-18 18:18:08 +02:00
|
|
|
let element = Element { attrs: Vec::new() };
|
2023-06-12 16:55:36 +08:00
|
|
|
unsafe { let () = element.get_attr("foo"); };
|
2017-06-18 18:18:08 +02:00
|
|
|
}
|