summaryrefslogtreecommitdiffstats
path: root/src/test/ui/issues/issue-5666.rs
blob: 810895b1b1bc4e40c39e009c6b88f816da09a7c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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()});
    let barker = [snoopy as Box<dyn Barks>, bubbles as Box<dyn Barks>];

    for pup in &barker {
        println!("{}", pup.bark());
    }
}