Skip to content

InMemoryIndex: use default trait #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 2 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -48,10 +49,7 @@ pub type Hit = Vec<u8>;
impl InMemoryIndex {
/// Create a new, empty index.
pub fn new() -> InMemoryIndex {
InMemoryIndex {
word_count: 0,
map: HashMap::new()
}
InMemoryIndex::default()
}

/// Index a single document.
Expand Down