blob: e62742bac5c74a42be062055b33cffd58253b0bf (
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
27
28
29
30
31
32
33
34
35
|
// run-pass
#![allow(dead_code)]
#![allow(unused_mut)]
#![allow(unused_variables)]
use std::io::{self, Write};
trait Trait {
fn f(&self);
}
#[derive(Copy, Clone)]
struct Struct {
x: isize,
y: isize,
}
impl Trait for Struct {
fn f(&self) {
println!("Hi!");
}
}
fn foo(mut a: Box<dyn Write>) {}
pub fn main() {
let a = Struct { x: 1, y: 2 };
let b: Box<dyn Trait> = Box::new(a);
b.f();
let c: &dyn Trait = &a;
c.f();
let out = io::stdout();
foo(Box::new(out));
}
|