blob: 9189bef2f7d012ccef536c56d9f9665f7b426eb7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#![allow(unused_variables)]
#[derive(Debug)]
struct File;
trait Read {
fn read(self: &Self, save_to: &mut Vec<u8>) -> Result<usize, String>;
}
impl Read for File {
fn read(self: &File, save_to: &mut Vec<u8>) -> Result<usize, String> {
Ok(0)
}
}
fn main() {
let f = File{};
let mut buffer = vec!();
let n_bytes = f.read(&mut buffer).unwrap();
println!("{} byte(s) read from {:?}", n_bytes, f);
}
|