Git Product home page Git Product logo

hash32's Introduction

hash32's People

Contributors

addisoncrump avatar bors[bot] avatar dirbaio avatar japaric avatar korken89 avatar liamolucko avatar mabezdev avatar xosplicer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hash32's Issues

Add support for tuples

It seems that tuples containing only types that implement hash32::Hash don't implement Hash themselves:

the trait bound `(u16, u16): hash32::Hash` is not satisfied
  --> examples/dw1000_rx_tx.rs:41:27
   |
41 |     let mut known_nodes = FnvIndexSet::<_, heapless::consts::U64>::new();
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `hash32::Hash` is not implemented for `(u16, u16)`
   |
   = note: required by `<heapless::indexset::IndexSet<T, N, hash32::BuildHasherDefault<S>>>::new`

It would be very useful to have this.

Extend `core::hash` instead of replacing it

It's possible to implement hash32::Hasher as an extension of core::hash::Hasher, rather than a replacement:

pub trait Hasher: core::hash::Hasher {
    // This isn't the best name, but calling it `finish` would conflict with the method of `core::hash::Hasher`.
    fn finish32(&self) -> u32;
}

This would allow using the standard Hash type instead of needing a custom version, and also remove the need for a custom derive macro.

Obviously, this would be a breaking change. Even if everything else was kept the same, and a blanket impl of core::hash::Hasher for hash32::Hasher was used instead of modifying hash32::Hasher, that would break any crates which already implemented both.

I've made a draft implementation at https://github.com/Liamolucko/hash32/tree/use-std.

Add support for enums

I'm getting the following error when trying to derive Hash32 for an enum:

error: proc-macro derive panicked
   --> src/mac.rs:464:40
    |
464 | #[derive(Clone, Copy, Debug, Eq, Hash, Hash32, PartialEq)]
    |                                        ^^^^^^
    |
    = help: message: #[derive(Hash)] doesn't currently support `enum` and `union`

It would be very useful to have support for enums!

"can't find crate for `hash32`"

When depending on the hash32 create, but not the hash crate, I'm getting the following error when trying to derive Hash32:

error[E0463]: can't find crate for `hash32`                                                              
   --> src/mac.rs:299:40                                                                                 
    |                                                                                                    
299 | #[derive(Clone, Copy, Debug, Eq, Hash, Hash32, PartialEq)]                                         
    |                                        ^^^^^^ can't find crate                                     

If I also add a dependency on hash32, the error goes away and everything works as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.