mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
982b49494e
This is to make the diff when stabilizing it easier to review.
27 lines
496 B
Rust
27 lines
496 B
Rust
// check-pass
|
|
|
|
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() };
|
|
unsafe { let () = element.get_attr("foo"); };
|
|
}
|