Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::fs::read #79

Merged
merged 1 commit into from
Sep 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("/dev/stdin").unwrap();
let ilen = seq.len();

// Remove headers and newlines.
Expand Down