From ef7ba96d4a3f2107c386aa33860e707b812ab732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 6 Jan 2019 11:23:42 +0100 Subject: [PATCH] feat: Introducing the Matches as_matches method --- examples/query-database.rs | 4 ++-- src/rank/mod.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/query-database.rs b/examples/query-database.rs index ce64870a9..edd311f16 100644 --- a/examples/query-database.rs +++ b/examples/query-database.rs @@ -115,7 +115,7 @@ fn main() -> Result<(), Box> { }; print!("{}: ", name); - let areas = create_highlight_areas(&text, &doc.matches, attr); + let areas = create_highlight_areas(&text, doc.matches.as_matches(), attr); display_highlights(&text, &areas)?; println!(); } @@ -124,7 +124,7 @@ fn main() -> Result<(), Box> { } let mut matching_attributes = HashSet::new(); - for _match in doc.matches { + for _match in doc.matches.as_matches() { let attr = SchemaAttr::new(_match.attribute.attribute()); let name = schema.attribute_name(attr); matching_attributes.insert(name); diff --git a/src/rank/mod.rs b/src/rank/mod.rs index ad91830bf..5416ca882 100644 --- a/src/rank/mod.rs +++ b/src/rank/mod.rs @@ -71,6 +71,10 @@ impl Matches { windows: self.slices.windows(2), } } + + pub fn as_matches(&self) -> &[Match] { + &self.matches + } } pub struct QueryIndexGroups<'a, 'b> {