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 {