From 2172fe78615275d13d9c7c9b9d5251d8186c2cb9 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 17 Nov 2020 21:30:44 -0500 Subject: [PATCH 1/5] Remove use of deprecated function `Error::description` --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index eec7757..3dc003d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,6 @@ mod write; mod merge; mod tmp; -use std::error::Error; use std::fs::File; use std::io; use std::io::prelude::*; @@ -298,6 +297,6 @@ fn main() { match run(filenames, single_threaded) { Ok(()) => {} - Err(err) => println!("error: {:?}", err.description()) + Err(err) => println!("error: {}", err) } } From 8c55dd6a15b784e18e1b2fd5a7674163297e4fc9 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 17 Nov 2020 21:33:36 -0500 Subject: [PATCH 2/5] Start `use` paths to local modules with `crate::` This was changed automatically with `cargo fix --edition`. --- src/main.rs | 8 ++++---- src/merge.rs | 6 +++--- src/read.rs | 2 +- src/write.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3dc003d..ad343e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,10 +30,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`. 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/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. From ddc46c90b0f4ac29ae40dc71abf543875baa3c12 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 17 Nov 2020 21:34:36 -0500 Subject: [PATCH 3/5] Rename the `try` variable to `r#try` This was changed automatically with `cargo fix --edition`. I could also see this being renamed to something else. --- src/tmp.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } } } From 9bf880ad96be9a8222a3bb68e975670120a28909 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 17 Nov 2020 21:36:02 -0500 Subject: [PATCH 4/5] Update to edition 2018 --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) 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" From ce5702f2ced4c6904f5669324e42021041f192de Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 17 Nov 2020 21:36:39 -0500 Subject: [PATCH 5/5] Remove `extern crate`s That are no longer needed in 2018 edition Rust. --- src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ad343e9..ab45791 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,9 +13,6 @@ /// 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;