From 8f2013dc13f1077acdceacc682834fa155f07035 Mon Sep 17 00:00:00 2001 From: Horki Date: Sat, 29 May 2021 19:14:29 +0200 Subject: [PATCH] InMemoryIndex: use default trait --- src/index.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.rs b/src/index.rs index 68b1b6b..7105dfc 100644 --- a/src/index.rs +++ b/src/index.rs @@ -21,6 +21,7 @@ fn tokenize(text: &str) -> Vec<&str> { /// answer simple search queries. And you can use the `read`, `write`, and /// `merge` modules to save an in-memory index to disk and merge it with other /// indices, producing a large index. +#[derive(Default)] pub struct InMemoryIndex { /// The total number of words in the indexed documents. pub word_count: usize, @@ -48,10 +49,7 @@ pub type Hit = Vec; impl InMemoryIndex { /// Create a new, empty index. pub fn new() -> InMemoryIndex { - InMemoryIndex { - word_count: 0, - map: HashMap::new() - } + InMemoryIndex::default() } /// Index a single document.