From 7f78d1f4ca8ffb3ab939fd344476f2e4d498c06f Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Thu, 23 Feb 2017 08:33:59 +0900 Subject: [PATCH] Fixes #82 Renamed and commented the function to create Term from &[u8] --- src/core/term_iterator.rs | 2 +- src/schema/term.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/term_iterator.rs b/src/core/term_iterator.rs index 3a5e259f7..ab2f125c7 100644 --- a/src/core/term_iterator.rs +++ b/src/core/term_iterator.rs @@ -100,7 +100,7 @@ impl<'a> TermIterator<'a> { for segment_ord in self.current_segment_ords.drain(..) { if let Some(term) = self.key_streams[segment_ord].next() { self.heap.push(HeapItem { - term: Term::from(term), + term: Term::from_bytes(term), segment_ord: segment_ord, }); } diff --git a/src/schema/term.rs b/src/schema/term.rs index 305aac6b6..c26fcc99f 100644 --- a/src/schema/term.rs +++ b/src/schema/term.rs @@ -11,7 +11,6 @@ use std::str; #[derive(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct Term(Vec); - impl Term { /// Pre-allocate a term buffer. @@ -64,6 +63,14 @@ impl Term { Term(buffer) } + /// Builds a term from its byte representation. + /// + /// If you want to build a field for a given `str`, + /// you want to use `from_field_text`. + pub fn from_bytes(data: &[u8]) -> Term { + Term(Vec::from(data)) + } + /// Returns the serialized value of the term. /// (this does not include the field.) /// @@ -96,12 +103,6 @@ impl Term { } } -impl<'a> From<&'a [u8]> for Term { - fn from(data: &[u8]) -> Term { - Term(Vec::from(data)) - } -} - impl AsRef<[u8]> for Term { fn as_ref(&self) -> &[u8] { &self.0 @@ -115,7 +116,6 @@ impl fmt::Debug for Term { } - #[cfg(test)] mod tests {