rust/src/test/ui/issues/issue-11740.rs
2018-12-25 21:08:33 -07:00

29 lines
532 B
Rust

// compile-pass
// skip-codegen
#![allow(warnings)]
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
});
}
}
fn main() {
let element = Element { attrs: Vec::new() };
let _ = unsafe { element.get_attr("foo") };
}