Code cleaning

This commit is contained in:
Paul Masurel
2017-05-18 23:06:02 +09:00
parent ca76fd5ba0
commit 0272167c2e
7 changed files with 58 additions and 43 deletions

View File

@@ -129,7 +129,8 @@ mod tests {
use super::*;
use directory::{RAMDirectory, Directory};
use std::path::PathBuf;
use fst::Streamer;
#[test]
fn test_fstmap() {
let mut directory = RAMDirectory::create();
@@ -146,10 +147,12 @@ mod tests {
assert_eq!(fstmap.get("abc"), Some(34u32));
assert_eq!(fstmap.get("abcd"), Some(346u32));
let mut stream = fstmap.stream();
assert!(stream.advance());
assert_eq!(stream.next().unwrap(), "abc".as_bytes());
assert_eq!(stream.key(), "abc".as_bytes());
assert!(stream.advance());
assert_eq!(stream.value(), 34u32);
assert_eq!(stream.next().unwrap(), "abcd".as_bytes());
assert_eq!(stream.key(), "abcd".as_bytes());
assert_eq!(stream.value(), 346u32);
assert!(!stream.advance());
}

View File

@@ -142,7 +142,7 @@ impl<'a, V> Streamer<'a> for FstMerger<'a, V> where V: BinarySerializable {
#[cfg(test)]
mod tests {
use super::*;
use schema::{Term, SchemaBuilder, Document, TEXT};
use core::Index;

View File

@@ -59,11 +59,11 @@ pub struct FstMapStreamer<'a, V> where V: 'a + BinarySerializable {
}
impl<'a, V> fst::Streamer<'a> for FstMapStreamer<'a, V> where V: 'a + BinarySerializable {
impl<'a, 'b, V> fst::Streamer<'b> for FstMapStreamer<'a, V> where V: 'a + BinarySerializable {
type Item = &'a [u8];
type Item = &'b [u8];
fn next<'b>(&'b mut self) -> Option<&'b [u8]> {
fn next(&'b mut self) -> Option<&'b [u8]> {
if self.advance() {
Some(&self.buffer)
}