AoC2019/src/intcode/icio.rs

24 lines
467 B
Rust

use std::io;
pub trait IntCodeIO {
fn get(&mut self) -> isize;
fn put(&mut self, value: isize);
}
pub struct StdAdapter;
impl IntCodeIO for StdAdapter {
fn get(&mut self) -> isize {
let mut value = String::new();
let _ = io::stdin()
.read_line(&mut value)
.expect("Unable to read stdin");
value.trim().parse().unwrap()
}
fn put(&mut self, value: isize) {
println!("{}", value);
}
}