Create a file called "output.txt", and place in it the contents of the file "input.txt" via an intermediate variable.


Note: This doesn't keep the file in memory. Buffering is provided by lazy evaluation.

main = readFile "input.txt" >>= writeFile "output.txt"


Note: The program will panic with any sort of error.

use std::fs::File;
use std::io::{Read, Write};

fn main() {
  let mut file = File::open("input.txt").unwrap();
  let mut data = Vec::new();
  file.read_to_end(&mut data).unwrap();
  let mut file = File::create("output.txt").unwrap();