// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. // compile-pass // skip-codegen #![allow(warnings)] struct Attr { name: String, value: String, } struct Element { attrs: Vec>, } impl Element { pub unsafe fn get_attr<'a>(&'a self, name: &str) { self.attrs .iter() .find(|attr| { let attr: &&Box = std::mem::transmute(attr); true }); } } fn main() { let element = Element { attrs: Vec::new() }; let _ = unsafe { element.get_attr("foo") }; }