rust/tests/ui/issues/issue-5666.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
489 B
Rust
Raw Normal View History

// run-pass
struct Dog {
name : String
}
trait Barks {
fn bark(&self) -> String;
}
impl Barks for Dog {
fn bark(&self) -> String {
return format!("woof! (I'm {})", self.name);
}
}
pub fn main() {
let snoopy = Box::new(Dog{name: "snoopy".to_string()});
let bubbles = Box::new(Dog{name: "bubbles".to_string()});
2019-05-28 18:47:21 +00:00
let barker = [snoopy as Box<dyn Barks>, bubbles as Box<dyn Barks>];
2015-01-31 17:20:46 +00:00
for pup in &barker {
2013-09-30 02:23:57 +00:00
println!("{}", pup.bark());
}
}