[][src]Function pancakestack::interpret::run_program_from_read

pub fn run_program_from_read<P, I, O>(
    program: P,
    input: I,
    output: O
) -> Result<(), Error> where
    P: Read,
    I: Read,
    O: Write

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.