From 66f1fe1dba9a1b80742d9e16e13bdf2b41211e35 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 17 Sep 2018 16:59:55 -0700 Subject: [PATCH] Use std::fs::read --- src/regex_redux.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/regex_redux.rs b/src/regex_redux.rs index dfe2343..746168d 100644 --- a/src/regex_redux.rs +++ b/src/regex_redux.rs @@ -10,26 +10,14 @@ extern crate regex; use std::borrow::Cow; -use std::fs::File; -use std::io::{self, Read}; +use std::fs; use std::sync::Arc; use std::thread; macro_rules! regex { ($re:expr) => { ::regex::bytes::Regex::new($re).unwrap() } } -/// Read the input into memory. -fn read() -> io::Result> { - // Pre-allocate a buffer based on the input file size. - let mut stdin = File::open("/dev/stdin")?; - let size = stdin.metadata()?.len() as usize; - let mut buf = Vec::with_capacity(size + 1); - - stdin.read_to_end(&mut buf)?; - Ok(buf) -} - fn main() { - let mut seq = read().unwrap(); + let mut seq = fs::read("/de/stdin").unwrap(); let ilen = seq.len(); // Remove headers and newlines.