use from instead of input

This commit is contained in:
Stefan Schwarz 2020-04-20 23:04:35 +02:00
parent 35a15fb23f
commit 7277571162

View file

@ -94,9 +94,9 @@ impl From<i64> for ModedOpcode {
let a = i % 1000 >= 100;
let b = i % 10000 >= 1000;
let c = i > 10000;
let modes = (Mode::from(a), Mode::from(b), Mode::from(c)).into();
let modes = (Mode::from(a), Mode::from(b), Mode::from(c));
ModedOpcode {
modes: modes,
modes: Modes::from(modes),
op: Opcode::from(code),
}
}
@ -132,7 +132,7 @@ impl From<File> for Computer {
* sign
})
.collect();
program.into()
Computer::from(program)
}
}
@ -160,7 +160,7 @@ impl Computer {
fn clone_with_input(&self, input: Vec<i64>) -> Computer {
let mut computer = self.clone();
computer.inputs = input.into();
computer.inputs = VecDeque::from(input);
computer
}
@ -195,8 +195,8 @@ impl Computer {
fn step(&mut self) {
let instruction = self.program[self.pos];
let instruction = ModedOpcode::from(instruction);
self.modes = (&instruction).into();
let advance = match (&instruction).into() {
self.modes = Modes::from(&instruction);
let advance = match Opcode::from(&instruction) {
Opcode::Add => self.add(),
Opcode::Multiply => self.multiply(),
Opcode::Input => self.input(),