Skip to content

Commit 66f1fe1

Browse files
committed
Use std::fs::read
1 parent fc1c52e commit 66f1fe1

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/regex_redux.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,14 @@
1010
extern crate regex;
1111

1212
use std::borrow::Cow;
13-
use std::fs::File;
14-
use std::io::{self, Read};
13+
use std::fs;
1514
use std::sync::Arc;
1615
use std::thread;
1716

1817
macro_rules! regex { ($re:expr) => { ::regex::bytes::Regex::new($re).unwrap() } }
1918

20-
/// Read the input into memory.
21-
fn read() -> io::Result<Vec<u8>> {
22-
// Pre-allocate a buffer based on the input file size.
23-
let mut stdin = File::open("/dev/stdin")?;
24-
let size = stdin.metadata()?.len() as usize;
25-
let mut buf = Vec::with_capacity(size + 1);
26-
27-
stdin.read_to_end(&mut buf)?;
28-
Ok(buf)
29-
}
30-
3119
fn main() {
32-
let mut seq = read().unwrap();
20+
let mut seq = fs::read("/de/stdin").unwrap();
3321
let ilen = seq.len();
3422

3523
// Remove headers and newlines.

0 commit comments

Comments
 (0)