diff --git a/Cargo.toml b/Cargo.toml index b895894..a5991f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "fingertips" version = "0.1.0" authors = ["Jason Orendorff "] +edition = "2018" [dependencies] argparse = "0.2.1" diff --git a/src/main.rs b/src/main.rs index eec7757..ab45791 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,16 +13,12 @@ /// The `main` function at the end handles command-line arguments. It calls one /// of the two functions above to do the work. -extern crate argparse; -extern crate byteorder; - mod index; mod read; mod write; mod merge; mod tmp; -use std::error::Error; use std::fs::File; use std::io; use std::io::prelude::*; @@ -31,10 +27,10 @@ use std::sync::mpsc::{channel, Receiver}; use std::thread::{spawn, JoinHandle}; use argparse::{ArgumentParser, StoreTrue, Collect}; -use index::InMemoryIndex; -use write::write_index_to_tmp_file; -use merge::FileMerge; -use tmp::TmpDir; +use crate::index::InMemoryIndex; +use crate::write::write_index_to_tmp_file; +use crate::merge::FileMerge; +use crate::tmp::TmpDir; /// Create an inverted index for the given list of `documents`, /// storing it in the specified `output_dir`. @@ -298,6 +294,6 @@ fn main() { match run(filenames, single_threaded) { Ok(()) => {} - Err(err) => println!("error: {:?}", err.description()) + Err(err) => println!("error: {}", err) } } diff --git a/src/merge.rs b/src/merge.rs index 038dfc5..2a1adc7 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -3,9 +3,9 @@ use std::io::{self, BufWriter}; use std::mem; use std::path::{Path, PathBuf}; -use tmp::TmpDir; -use read::IndexFileReader; -use write::IndexFileWriter; +use crate::tmp::TmpDir; +use crate::read::IndexFileReader; +use crate::write::IndexFileWriter; pub struct FileMerge { output_dir: PathBuf, diff --git a/src/read.rs b/src/read.rs index 30f50df..460a797 100644 --- a/src/read.rs +++ b/src/read.rs @@ -6,7 +6,7 @@ use std::io::prelude::*; use std::io::{self, BufReader, SeekFrom}; use std::path::Path; use byteorder::{LittleEndian, ReadBytesExt}; -use write::IndexFileWriter; +use crate::write::IndexFileWriter; /// A `IndexFileReader` does a single linear pass over an index file from /// beginning to end. Needless to say, this is not how an index is normally diff --git a/src/tmp.rs b/src/tmp.rs index 443eeb4..54d4b97 100644 --- a/src/tmp.rs +++ b/src/tmp.rs @@ -17,7 +17,7 @@ impl TmpDir { } pub fn create(&mut self) -> io::Result<(PathBuf, BufWriter)> { - let mut try = 1; + let mut r#try = 1; loop { let filename = self.dir.join(PathBuf::from(format!("tmp{:08x}.dat", self.n))); self.n += 1; @@ -29,13 +29,13 @@ impl TmpDir { Ok(f) => return Ok((filename, BufWriter::new(f))), Err(exc) => - if try < 999 && exc.kind() == io::ErrorKind::AlreadyExists { + if r#try < 999 && exc.kind() == io::ErrorKind::AlreadyExists { // keep going } else { return Err(exc); } } - try += 1; + r#try += 1; } } } diff --git a/src/write.rs b/src/write.rs index ee30c60..b42f384 100644 --- a/src/write.rs +++ b/src/write.rs @@ -2,8 +2,8 @@ use std::fs::File; use std::io::{self, BufWriter, SeekFrom}; use std::io::prelude::*; use std::path::PathBuf; -use index::InMemoryIndex; -use tmp::TmpDir; +use crate::index::InMemoryIndex; +use crate::tmp::TmpDir; use byteorder::{LittleEndian, WriteBytesExt}; /// Writer for saving an index to a binary file.