Skip to content

Instantly share code, notes, and snippets.

@ichyo
Last active January 22, 2018 07:59
Show Gist options
  • Save ichyo/74391d4c1721c3607a9c3d37dadf4768 to your computer and use it in GitHub Desktop.
Save ichyo/74391d4c1721c3607a9c3d37dadf4768 to your computer and use it in GitHub Desktop.
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::path::Path;
fn open<P: AsRef<Path>>(path: P) -> Result<std::io::Lines<BufReader<File>>, std::io::Error> {
let file = File::open(path)?;
let reader = BufReader::new(file);
Ok(reader.lines())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment