Fixes #82 Renamed and commented the function to create Term from &[u8]

This commit is contained in:
Paul Masurel
2017-02-23 08:33:59 +09:00
parent a74b41d7ed
commit 7f78d1f4ca
2 changed files with 9 additions and 9 deletions

View File

@@ -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,
});
}

View File

@@ -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 {