mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-06-01 16:10:42 +00:00
Fixes #82 Renamed and commented the function to create Term from &[u8]
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ use std::str;
|
||||
#[derive(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||
pub struct Term(Vec<u8>);
|
||||
|
||||
|
||||
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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user