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

Added optional support for mem-dbg #14

Open
wants to merge 2 commits 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Enable better performance on 32-bit systems via the `mum32bit` feature.
- Benchmarks.
- Added derives for `Debug`, `PartialEq`, `Eq`, `PartialOrd`, `Ord`, `Copy`, and `Hash` for all structs where applicable in the crate.
- Added optional support for [`mem_dbg`](https://github.com/zommiommy/mem_dbg-rs), a memory requirements estimation tool.
- Added feature `mem_dbg` to enable the optional support for `mem_dbg`.
- Added feature `std` to enable optionally the standard library.

### Changed
- [breaking-change] Changed default version to `final3`. The previous version
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include = [
edition = "2018"

[dependencies]
mem_dbg = {version="0.2.4", optional=true}
rand_core = "0.6"

[dev-dependencies]
Expand All @@ -31,6 +32,8 @@ twox-hash = "=1.6.0"

[features]
mum32bit = []
std = []
mem_dbg = ["dep:mem_dbg", "std"]

[workspace]
members = ["comparison"]
Expand Down
2 changes: 2 additions & 0 deletions src/final3/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rand_core::{impls, Error, RngCore, SeedableRng};

/// WyHash hasher
#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Copy, Hash)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct WyHash {
seed: u64,
a: u64,
Expand Down Expand Up @@ -52,6 +53,7 @@ impl Hasher for WyHash {

/// WyRng random number generator
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct WyRng(u64);

impl RngCore for WyRng {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
//! ```

#![doc(html_root_url = "https://docs.rs/wyhash/0.5.0")]
#![no_std]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(missing_docs, unsafe_code)]

/// WyHash version 1
Expand Down
2 changes: 2 additions & 0 deletions src/v1/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use rand_core::{impls, Error, RngCore, SeedableRng};

/// WyHash hasher
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct WyHash {
h: u64,
size: u64,
Expand Down Expand Up @@ -36,6 +37,7 @@ impl Hasher for WyHash {

/// WyRng random number generator
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct WyRng(u64);

impl RngCore for WyRng {
Expand Down