feat: Implement Debug on RawDocument for more convenience

This commit is contained in:
Clément Renault 2019-05-20 11:19:56 +02:00
parent 6df8f62022
commit 94f9587db1
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE

View File

@ -4,6 +4,7 @@ mod query_builder;
mod store;
pub mod criterion;
use std::fmt;
use std::sync::Arc;
use rayon::slice::ParallelSliceMut;
@ -210,6 +211,21 @@ impl RawDocument {
}
}
impl fmt::Debug for RawDocument {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RawDocument")
.field("id", &self.id)
.field("query_index", &self.query_index())
.field("distance", &self.distance())
.field("attribute", &self.attribute())
.field("word_index", &self.word_index())
.field("is_exact", &self.is_exact())
.field("char_index", &self.char_index())
.field("char_length", &self.char_length())
.finish()
}
}
pub fn raw_documents_from_matches(mut matches: Vec<(DocumentId, Match)>) -> Vec<RawDocument> {
let mut docs_ranges = Vec::<(DocumentId, Range)>::new();
let mut matches2 = Matches::with_capacity(matches.len());