From c8d06d63b94a9c088fc2ac01ed53789f30026e1c Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Sat, 15 Apr 2017 09:43:12 +0900 Subject: [PATCH] Test on UTF-8 --- src/common/counting_writer.rs | 4 ++-- src/core/term_iterator.rs | 2 +- src/datastruct/stream_dictionary.rs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/counting_writer.rs b/src/common/counting_writer.rs index 9facc4872..d7a6ed5db 100644 --- a/src/common/counting_writer.rs +++ b/src/common/counting_writer.rs @@ -47,8 +47,8 @@ mod test { #[test] fn test_counting_writer() { - let mut w: Vec = vec!(); - let mut counting_writer = CountingWriter::wrap(w); + let buffer: Vec = vec!(); + let mut counting_writer = CountingWriter::wrap(buffer); let bytes = (0u8..10u8).collect::>(); counting_writer.write_all(&bytes).unwrap(); let (w, len): (Vec, usize) = counting_writer.finish().unwrap(); diff --git a/src/core/term_iterator.rs b/src/core/term_iterator.rs index 5ac68f929..03f690015 100644 --- a/src/core/term_iterator.rs +++ b/src/core/term_iterator.rs @@ -99,7 +99,7 @@ impl<'a> TermIterator<'a> { fn advance_segments(&mut self) { for segment_ord in self.current_segment_ords.drain(..) { - if let Some((term, val)) = self.key_streams[segment_ord].next() { + if let Some((term, _val)) = self.key_streams[segment_ord].next() { self.heap.push(HeapItem { term: Term::from_bytes(term), segment_ord: segment_ord, diff --git a/src/datastruct/stream_dictionary.rs b/src/datastruct/stream_dictionary.rs index a725b26c6..942ffe5fe 100644 --- a/src/datastruct/stream_dictionary.rs +++ b/src/datastruct/stream_dictionary.rs @@ -266,7 +266,7 @@ fn get_offset<'a, V, P: Fn(&[u8])->bool>(predicate: P, mut streamer: StreamDicti impl<'a, V: 'a + BinarySerializable + Clone + Default> StreamDictionaryStreamerBuilder<'a, V> { pub fn ge(mut self, target_key: &[u8]) -> StreamDictionaryStreamerBuilder<'a, V> { - let mut streamer = stream_before(&self.stream_dictionary, target_key.as_ref()); + let streamer = stream_before(&self.stream_dictionary, target_key.as_ref()); let smaller_than = |k: &[u8]| { k.lt(target_key) }; let (offset_before, current_key, _) = get_offset(smaller_than, streamer); self.current_key = current_key; @@ -275,7 +275,7 @@ impl<'a, V: 'a + BinarySerializable + Clone + Default> StreamDictionaryStreamerB } pub fn gt(mut self, target_key: &[u8]) -> StreamDictionaryStreamerBuilder<'a, V> { - let mut streamer = stream_before(self.stream_dictionary, target_key.as_ref()); + let streamer = stream_before(self.stream_dictionary, target_key.as_ref()); let smaller_than = |k: &[u8]| { k.le(target_key) }; let (offset_before, current_key, _) = get_offset(smaller_than, streamer); self.current_key = current_key; @@ -284,7 +284,7 @@ impl<'a, V: 'a + BinarySerializable + Clone + Default> StreamDictionaryStreamerB } pub fn lt(mut self, target_key: &[u8]) -> StreamDictionaryStreamerBuilder<'a, V> { - let mut streamer = stream_before(self.stream_dictionary, target_key.as_ref()); + let streamer = stream_before(self.stream_dictionary, target_key.as_ref()); let smaller_than = |k: &[u8]| { k.le(target_key) }; let (_, _, offset_after) = get_offset(smaller_than, streamer); self.offset_to = offset_after; @@ -292,7 +292,7 @@ impl<'a, V: 'a + BinarySerializable + Clone + Default> StreamDictionaryStreamerB } pub fn le(mut self, target_key: &[u8]) -> StreamDictionaryStreamerBuilder<'a, V> { - let mut streamer = stream_before(self.stream_dictionary, target_key.as_ref()); + let streamer = stream_before(self.stream_dictionary, target_key.as_ref()); let smaller_than = |k: &[u8]| { k.lt(target_key) }; let (_, _, offset_after) = get_offset(smaller_than, streamer); self.offset_to = offset_after; @@ -408,7 +408,7 @@ mod test { for j in 0..3 { let (streamer_k, streamer_v) = streamer.next().unwrap(); let &(ref key, ref v) = &ids[i + j]; - assert_eq!(streamer_k, key.as_bytes()); + assert_eq!(str::from_utf8(streamer_k).unwrap(), key); assert_eq!(streamer_v, v); } }