summary refs log tree commit diff
path: root/src/test/run-pass/explicit-self-objects-ext-4.rs
blob: 759097a771b15d62c3e346b5693b4aa4913a043a (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
36
37
38
39
pub trait Reader {
    // FIXME (#2004): Seekable really should be orthogonal.

    /// Read up to len bytes (or EOF) and put them into bytes (which
    /// must be at least len bytes long). Return number of bytes read.
    // FIXME (#2982): This should probably return an error.
    fn read(bytes: &[mut u8], len: uint) -> uint;
}

pub trait ReaderUtil {

    /// Read len bytes into a new vec.
    fn read_bytes(len: uint);
}

impl<T: Reader> T : ReaderUtil {

    fn read_bytes(len: uint) {
        let count = self.read(&[mut 0], len);
    }

}

struct S {
    x: int,
    y: int
}

impl S: Reader {
    fn read(bytes: &[mut u8], len: uint) -> uint {
        0
    }
}

fn main() {
    let x = S { x: 1, y: 2 };
    let x = x as @Reader;
    x.read_bytes(0);
}