Skip to content

Commit

Permalink
Use std::fs::read
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrubeck committed Sep 17, 2018
1 parent fc1c52e commit 66f1fe1
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/regex_redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>> {
// 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.
Expand Down

0 comments on commit 66f1fe1

Please sign in to comment.