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

Using gen! in your own crate requires adding getrandom as a dependency #8

Closed
Mossop opened this issue Jun 5, 2023 · 5 comments
Closed

Comments

@Mossop
Copy link

Mossop commented Jun 5, 2023

For example with the following code:

nano_id::gen!(
    base_long_id,
    25,
    b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
);

If your crate doesn't declare a dependency on getrandom then you get this error:

error[E0433]: failed to resolve: use of undeclared crate or module `getrandom`
 --> packages/server/src/util.rs:4:1
  |
4 | / nano_id::gen!(
5 | |     base_long_id,
6 | |     25,
7 | |     b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
8 | | );
  | |_^ use of undeclared crate or module `getrandom`
  |
  = note: this error originates in the macro `nano_id::gen` (in Nightly builds, run with -Z macro-backtrace for more info)
@fundon
Copy link
Member

fundon commented Jun 2, 2024

Sorry to see it so late.
Have you solved it?

@Mossop
Copy link
Author

Mossop commented Jun 3, 2024

No, I just switched to using the base62 feature.

@fundon
Copy link
Member

fundon commented Jun 3, 2024

Add getrandom crate, can it be solved?

@Mossop
Copy link
Author

Mossop commented Jun 3, 2024

Yes it works if you manually add getrandom to your Cargo.toml

@fundon
Copy link
Member

fundon commented Jun 3, 2024

Thanks for the feedback.

@fundon fundon closed this as completed Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants