mac编译dbgen出错rand::rngs::OsRng

error[E0432]: unresolved import `rand::rngs::OsRng`

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0/src/cli.rs:19:27

|

19 | rngs::{mock::StepRng, OsRng},

| ^^^^^ no `OsRng` in `rngs`

|

note: found an item that was configured out

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rngs/mod.rs:119:50

|

119 | #[cfg(feature = "getrandom")] pub use rand_core::OsRng;

| ^^^^^

= note: the item is gated behind the `getrandom` feature

error[E0432]: unresolved import `rand::rngs::OsRng`

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0/src/schemagen_cli.rs:5:12

|

5 | use rand::{rngs::OsRng, seq::SliceRandom, Rng, RngCore, SeedableRng};

| ^^^^^^^^^^^ no `OsRng` in `rngs`

|

note: found an item that was configured out

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rngs/mod.rs:119:50

|

119 | #[cfg(feature = "getrandom")] pub use rand_core::OsRng;

| ^^^^^

= note: the item is gated behind the `getrandom` feature

分析:

网上和kimi提示添加依赖到Cargo.toml:

dependencies

rand = { version = "0.8", features = ["getrandom"] }

根据编译路径,找到/Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0,打开Cargo.toml,长这样:

dependencies.rand

version = "0.8.5"

default-features = false

修改false为true解决。

语法差别是rust 1.49 2018版本同rust 1.79的区别。

For more information about this error, try `rustc --explain E0432`.

error: could not compile `dbgen` (lib) due to 2 previous errors

error: failed to compile `dbgen v0.8.0`, intermediate artifacts can be found at `/var/folders/qn/sls3xhws4218snv410vq6x380000gn/T/cargo-installNSCX7t`.

相关推荐
蘑菇头爱平底锅2 分钟前
数字孪生-DTS-孪创城市-天气功能
前端·数据可视化
Moment7 分钟前
你写的网站安全吗?这四个攻击方式正在悄悄盯上你
前端·后端·面试
_荒12 分钟前
Uniapp 开发物联网项目MQTT通信使用和TTS语音播报以及无输入框扫描枪读取
前端·javascript·vue.js
遥不可及~~斌16 分钟前
基于Redis实现短信防轰炸的Java解决方案
java·数据库·redis
狂炫一碗大米饭17 分钟前
vue面试高频考题----computed和watch的区别❓
前端·vue.js·面试
AronTing42 分钟前
300%性能提升!CompletableFuture异步编排四大核心模式与避坑指南
java·后端·安全
Kant79342 分钟前
Ant Design X 和 Element-Plus-X
前端
dasseinzumtode1 小时前
在 React 项目中使用 TypeScript 编写 Service Worker 的完整方案
前端·react.js