added lifetime ... i guess
This commit is contained in:
@@ -18,23 +18,23 @@ pub struct Instruction {
|
|||||||
pub argument: usize,
|
pub argument: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Machine {
|
pub struct Machine<'a> {
|
||||||
ip: usize,
|
ip: usize,
|
||||||
mp: usize,
|
mp: usize,
|
||||||
code: Vec<Instruction>,
|
code: Vec<Instruction>,
|
||||||
memory: [u32; 50000],
|
memory: [u32; 50000],
|
||||||
input: &mut BufReader<Box<dyn Read>>,
|
input: &'a mut BufReader<Box<dyn Read>>,
|
||||||
output: &mut BufWriter<Box<dyn Write>>,
|
output: &'a mut BufWriter<Box<dyn Write>>,
|
||||||
buf: [u8; 1],
|
buf: [u8; 1],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Machine {
|
impl<'a> Machine<'a> {
|
||||||
pub fn new(code: Vec<Instruction>, input: &mut BufReader<Box<dyn Read>>, output: &mut BufWriter<Box<dyn Write>>) -> Self {
|
pub fn new(code: Vec<Instruction>, input: &'a mut BufReader<Box<dyn Read>>, output: &'a mut BufWriter<Box<dyn Write>>) -> Self {
|
||||||
Machine {
|
Machine {
|
||||||
ip: 0,
|
ip: 0,
|
||||||
mp: 0,
|
mp: 0,
|
||||||
code,
|
code,
|
||||||
memory: [0, 50000],
|
memory: [0; 50000],
|
||||||
input,
|
input,
|
||||||
output,
|
output,
|
||||||
buf: [0;1],
|
buf: [0;1],
|
||||||
|
|||||||
Reference in New Issue
Block a user