2015-03-17 15:33:26 -05:00
|
|
|
use std::io::{self, Read};
|
2014-09-11 17:54:44 -05:00
|
|
|
use std::vec;
|
|
|
|
|
|
|
|
pub struct Container<'a> {
|
2019-05-28 13:46:13 -05:00
|
|
|
reader: &'a mut dyn Read
|
2014-09-11 17:54:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Container<'a> {
|
2019-05-28 13:46:13 -05:00
|
|
|
pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> {
|
2014-09-11 17:54:44 -05:00
|
|
|
Container { reader: reader }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn read_to(&mut self, vec: &mut [u8]) {
|
|
|
|
self.reader.read(vec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn for_stdin<'a>() -> Container<'a> {
|
2015-03-17 15:33:26 -05:00
|
|
|
let mut r = io::stdin();
|
2019-05-28 13:46:13 -05:00
|
|
|
Container::wrap(&mut r as &mut dyn io::Read)
|
2014-09-11 17:54:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut c = for_stdin();
|
2015-01-02 01:53:35 -06:00
|
|
|
let mut v = Vec::new();
|
2016-11-09 17:25:45 -06:00
|
|
|
c.read_to(v); //~ ERROR E0308
|
2014-09-11 17:54:44 -05:00
|
|
|
}
|