diff --git a/Cargo.toml b/Cargo.toml index 4cea998..8321529 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "khash" description = "Kana hashes" -version = "2.0.1" +version = "2.0.2" authors = ["Avril "] edition = "2018" license = "GPL-3.0-or-later" diff --git a/Makefile b/Makefile index 02e8c43..82378b0 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ $(DEBUG)/lib$(PROJECT).so: .PHONY: khash-nonative khash-nonative: - $(MAKE) RUSTFLAGS="" $(BUILD)/libkhash.so + $(MAKE) $(BUILD)/libkhash.so .PHONY: test test: RUSTFLAGS+= -C target-cpu=native -C opt-level=3 diff --git a/src/sixteen.rs b/src/sixteen.rs index da6d1df..8ab88f6 100644 --- a/src/sixteen.rs +++ b/src/sixteen.rs @@ -15,17 +15,6 @@ where I: Iterator, type Item = u16; fn next(&mut self) -> Option { - /*let mut c = 0u16; - unsafe { - if let Some(a) = self.iter.next() { - crate::reinterpret::bytes_mut(&mut c)[0] = *a.borrow(); - } else { - return None; - } - if let Some(b) = self.iter.next() { - crate::reinterpret::bytes_mut(&mut c)[1] = *b.borrow(); - } - }*/ let mut ar = [0u8; std::mem::size_of::()]; if let Some(a) = self.iter.next() { @@ -39,8 +28,20 @@ where I: Iterator, } Some(u16::from_le_bytes(ar)) } + fn size_hint(&self) -> (usize, Option) { + let (l, h) = self.iter.size_hint(); + (l/2, h.map(|x| x/2)) + } } +impl std::iter::FusedIterator for Bit16Iter +where I: Iterator + std::iter::FusedIterator, +::Item: Borrow{} + +impl ExactSizeIterator for Bit16Iter +where I: Iterator + ExactSizeIterator, +::Item: Borrow{} + pub trait Bit16IterExt: Iterator + Sized where ::Item: Borrow {