Function pancakestack::interpret::run_program_from_read
source · pub fn run_program_from_read(
program: impl Read,
input: impl Read,
output: impl Write
) -> Result<(), Error>
Expand description
Parses and run the commands read from the given Read using the provided input and output. Each command has to be on its own line.
let file = File::open("example.pancake").unwrap();
let input = b"some input";
let mut output_buf = Vec::new();
pancakestack::run_program_from_read(file, &input[..], &mut output_buf).unwrap();
let output = std::str::from_utf8(&output_buf).unwrap();
Errors
Will return Err
if the given program performs an illegal operation or an io error occurs. See Error
.