From 7c825d9bb7a51e93c7f7f198b3d83a15fdb20db1 Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Wed, 15 Nov 2023 12:19:06 +0100 Subject: [PATCH 1/3] update to edition 2021 & set rust-version so far the crate used the default edition (2015). upgrading to the newest edition before having the first major release creates a stable platform on which to build in the future. the current edition is also already two years old, so it is likely that most consumers are already using a compatible rust version. for those which might not have upgraded it remains an option to use an existing release of the crate for the time being. setting [`rust-version`] allows having cleaner error messages for those using older rust compilers - though as of now this will not be particularly helpful as the field is only supported starting with rust 1.56 which is also the version introducing support for the 2021 edition. nevertheless, already specifying it now creates a base for future MSRV updates. note: all code changes were done by running `cargo fix --edition` as per the [upgrade guide]. [upgrade guide]: https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html [`rust-version`]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field --- Cargo.toml | 2 ++ src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3024267..254bf2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ license = "MIT OR Apache-2.0" name = "hash32" repository = "https://github.com/japaric/hash32" version = "0.3.1" +edition = "2021" +rust-version = "1.56" [dependencies.byteorder] default-features = false diff --git a/src/lib.rs b/src/lib.rs index 04a32be..d14bc26 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,8 +56,8 @@ use core::fmt; use core::hash::BuildHasher; use core::marker::PhantomData; -pub use fnv::Hasher as FnvHasher; -pub use murmur3::Hasher as Murmur3Hasher; +pub use crate::fnv::Hasher as FnvHasher; +pub use crate::murmur3::Hasher as Murmur3Hasher; mod fnv; mod murmur3; From fe18f1eacbf15e220207de9d6a76ca87d07f97c7 Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Wed, 15 Nov 2023 12:30:51 +0100 Subject: [PATCH 2/3] use `pointer::add` instead of `pointer::offset` (fix clippy warning) for details see [the clippy warning](https://rust-lang.github.io/rust-clippy/master/index.html#/ptr_offset_with_cast). --- src/murmur3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/murmur3.rs b/src/murmur3.rs index 8bbdbe4..f0c9082 100644 --- a/src/murmur3.rs +++ b/src/murmur3.rs @@ -139,7 +139,7 @@ impl core::hash::Hasher for Hasher { let mid = 4 - index; let head = unsafe { slice::from_raw_parts(bytes.as_ptr(), mid) }; let body = unsafe { - slice::from_raw_parts(bytes.as_ptr().offset(mid as isize), len - mid) + slice::from_raw_parts(bytes.as_ptr().add(mid), len - mid) }; // NOTE(unsafe) avoid calling `memcpy` on a 0-3 byte copy From a7343c31db533f58f9147ce0d801a8f32b9a760b Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Wed, 15 Nov 2023 12:37:15 +0100 Subject: [PATCH 3/3] add MSRV policy to README note that this is just a suggestion as a basis for discussion. some crates are doing this (updating with new patch release), others are much stricter. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index eeebdbb..7761eec 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,7 @@ at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +## Minimum Supported Rust Version (MSRV) +This crate is guaranteed to compile on stable Rust 1.56 and up. It *might* +compile with older versions but that may change in any new patch release.