Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Rust 2018 edition #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description = "Fast, SIMD-accelerated CRC32 (IEEE) checksum computation"
repository = "https://github.com/srijs/rust-crc32fast"
readme = "README.md"
keywords = ["checksum", "crc", "crc32", "simd", "fast"]
edition = "2018"

[dependencies]
cfg-if = "1.0"
Expand Down
6 changes: 4 additions & 2 deletions src/baseline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use table::CRC32_TABLE;
use crate::table::CRC32_TABLE;

#[derive(Clone)]
pub struct State {
Expand All @@ -23,7 +23,7 @@ impl State {
}

pub fn combine(&mut self, other: u32, amount: u64) {
self.state = ::combine::combine(self.state, other, amount);
self.state = crate::combine::combine(self.state, other, amount);
}
}

Expand Down Expand Up @@ -70,6 +70,8 @@ pub(crate) fn update_slow(prev: u32, buf: &[u8]) -> u32 {

#[cfg(test)]
mod test {
use quickcheck::quickcheck;

#[test]
fn slow() {
assert_eq!(super::update_slow(0, b""), 0);
Expand Down
10 changes: 1 addition & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
)]

#[deny(missing_docs)]
#[cfg(test)]
#[macro_use]
extern crate quickcheck;

#[macro_use]
extern crate cfg_if;

#[cfg(feature = "std")]
use std as core;

use core::fmt;
use core::hash;
Expand Down Expand Up @@ -159,6 +150,7 @@ impl hash::Hasher for Hasher {

#[cfg(test)]
mod test {
use quickcheck::quickcheck;
use super::Hasher;

quickcheck! {
Expand Down
2 changes: 2 additions & 0 deletions src/specialized/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub unsafe fn calculate(crc: u32, data: &[u8]) -> u32 {

#[cfg(test)]
mod test {
use quickcheck::quickcheck;

quickcheck! {
fn check_against_baseline(init: u32, chunks: Vec<(Vec<u8>, usize)>) -> bool {
let mut baseline = super::super::super::baseline::State::new(init);
Expand Down
2 changes: 2 additions & 0 deletions src/specialized/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use cfg_if::cfg_if;

cfg_if! {
if #[cfg(all(
crc32fast_stdarchx86,
Expand Down
8 changes: 5 additions & 3 deletions src/specialized/pclmulqdq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl State {
}

pub fn combine(&mut self, other: u32, amount: u64) {
self.state = ::combine::combine(self.state, other, amount);
self.state = crate::combine::combine(self.state, other, amount);
}
}

Expand Down Expand Up @@ -94,7 +94,7 @@ pub unsafe fn calculate(crc: u32, mut data: &[u8]) -> u32 {
// the fallback implementation as it's too much hassle and doesn't seem too
// beneficial.
if data.len() < 128 {
return ::baseline::update_fast_16(crc, data);
return crate::baseline::update_fast_16(crc, data);
}

// Step 1: fold by 4 loop
Expand Down Expand Up @@ -183,7 +183,7 @@ pub unsafe fn calculate(crc: u32, mut data: &[u8]) -> u32 {
let c = arch::_mm_extract_epi32(arch::_mm_xor_si128(x, t2), 1) as u32;

if !data.is_empty() {
::baseline::update_fast_16(!c, data)
crate::baseline::update_fast_16(!c, data)
} else {
!c
}
Expand All @@ -204,6 +204,8 @@ unsafe fn get(a: &mut &[u8]) -> arch::__m128i {

#[cfg(test)]
mod test {
use quickcheck::quickcheck;

quickcheck! {
fn check_against_baseline(init: u32, chunks: Vec<(Vec<u8>, usize)>) -> bool {
let mut baseline = super::super::super::baseline::State::new(init);
Expand Down