我是个生锈新手。我正在尝试使用包含Math::log
的板条箱js_sys
。正如crate网站告诉我的那样,我已经包含了js_sys = 0.3.48
,然后是main.rs
中的use js_sys::Math::log;
。我得到一个错误,rust找不到板条箱。
复制步骤:
在Cargo.toml
中
[package]
name = "sim"
version = "0.1.0"
authors = ["Excluded for privacy"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
js_sys = "0.3.48"
rand = "0.8.3"
在我的main.rs
顶部
// Luke Anglin and Tobi Solarin
use js_sys::Math::log;
use rand::prelude::*; // For the rng
const n: i32 = 1_000; // The number of trials
错误
error: no matching package named `js_sys` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
perhaps you meant: js-sys
required by package `sim v0.1.0 (/Users/lukeanglin/Desktop/Probability/Project2/simulator/sim)`
发布于 2021-03-16 22:58:20
在您的Cargo.toml中将js_sys更改为js-sys,它应该可以工作。(正如您发布的错误中所述,但很容易被忽略)
https://stackoverflow.com/questions/66664500
复制相似问题