Skip to content

Using aHash 0.5 with wasm #59

@emilk

Description

@emilk

Hi!

I found a small issue when using aHash with --target wasm32-unknown-unknown. Starting in aHash version 0.5 I get this:

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> /Users/emil.ernerfeldt/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.0/src/lib.rs:224:9
    |
224 | /         compile_error!("target is not supported, for more information see: \
225 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |_________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared type or module `imp`
   --> /Users/emil.ernerfeldt/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.0/src/lib.rs:246:5
    |
246 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared type or module `imp`

There is a simple workaround:

ahash = { version = "0.5", features = ["std"], default-features = false }
getrandom = { version = "0.2", features = ["js"] } # used by ahash

I was wondering if aHash could have some helpful feature flag for this (features = ["std", "wasm"]), or maybe even detect the wasm32 target? I'm not great with how Cargo.toml dependencies work :)

PS: I really love using aHash as a faster drop-in replacement for HashMap and HashSet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions