From 94f9587db1308e613fb490c9764acb25e33066c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 20 May 2019 11:19:56 +0200 Subject: [PATCH] feat: Implement Debug on RawDocument for more convenience --- meilidb-core/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/meilidb-core/src/lib.rs b/meilidb-core/src/lib.rs index 838d787dd..e61fa543b 100644 --- a/meilidb-core/src/lib.rs +++ b/meilidb-core/src/lib.rs @@ -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 { let mut docs_ranges = Vec::<(DocumentId, Range)>::new(); let mut matches2 = Matches::with_capacity(matches.len());