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`.

相关推荐
y25086 分钟前
《Object类》
java·开发语言
曙曙学编程7 分钟前
初级数据结构——树
android·java·数据结构
BestandW1shEs13 分钟前
彻底理解消息队列的作用及如何选择
java·kafka·rabbitmq·rocketmq
爱吃烤鸡翅的酸菜鱼15 分钟前
Java算法OJ(8)随机选择算法
java·数据结构·算法·排序算法
码蜂窝编程官方19 分钟前
【含开题报告+文档+PPT+源码】基于SpringBoot+Vue的虎鲸旅游攻略网的设计与实现
java·vue.js·spring boot·后端·spring·旅游
gqkmiss19 分钟前
Chrome 浏览器 131 版本开发者工具(DevTools)更新内容
前端·chrome·浏览器·chrome devtools
Summer不秃24 分钟前
Flutter之使用mqtt进行连接和信息传输的使用案例
前端·flutter
软件技术员27 分钟前
Let‘s Encrypt SSL证书:acmessl.cn申请免费3个月证书
服务器·网络协议·ssl
旭日猎鹰29 分钟前
Flutter踩坑记录(二)-- GestureDetector+Expanded点击无效果
前端·javascript·flutter
Viktor_Ye35 分钟前
高效集成易快报与金蝶应付单的方案
java·前端·数据库