为什么 Rust 找不到 "js_sys" 箱子?
Why can't Rust find the "js_sys" crate?
我是生锈新手。我正在尝试使用包含 Math::log
的板条箱 js_sys
。正如板条箱网站告诉我的那样,我已经包含了 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)`
在您的 Cargo.toml 中将 js_sys 更改为 js-sys,它应该可以工作。 (如您发布但容易被忽视的错误中所述)
我是生锈新手。我正在尝试使用包含 Math::log
的板条箱 js_sys
。正如板条箱网站告诉我的那样,我已经包含了 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)`
在您的 Cargo.toml 中将 js_sys 更改为 js-sys,它应该可以工作。 (如您发布但容易被忽视的错误中所述)