Avoiding a clone when loading the program from file
parent
b416a32ee7
commit
4b29043d58
|
@ -98,9 +98,9 @@ fn input() -> Vec<u8> {
|
||||||
|
|
||||||
fn load_program() -> Vec<u8> {
|
fn load_program() -> Vec<u8> {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
let input = args[1].clone();
|
let input = args.get(1).expect("malformed arguments");
|
||||||
|
|
||||||
let path: PathBuf = input.into();
|
let path: PathBuf = input.into();
|
||||||
let input = fs::read_to_string(path).unwrap();
|
let input = fs::read_to_string(path).expect("failed to read the program file");
|
||||||
input.as_bytes().to_vec()
|
input.as_bytes().to_vec()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue