我正在按照《Rust编程语言》一书中的指示构建一个猜数字游戏,但是每当我尝试在VSCodium(VSCode的开源版本)终端中运行我的代码(通过命令Cargo run
),我的代码由于以下错误而拒绝运行:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
这是我的 Cargo.toml 文件的样子:
[package]
name = "GuessingGame"
path = "src/GuessingGame.rs"
version = "0.1.0"
edition = "2021"
authors = ["my name <example@example.com>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
版本: VSCodium: 1.73.1 操作系统: Zorin OS 16.2
我尝试将 [package]
更改为 [[bin]]
和 [lib]
,但这给了我更多的错误,分别是:
this virtual manifest specifies a [lib] section, which is not allowed
和
this virtual manifest specifies a [[bin]] section, which is not allowed
cargo build
吗?在src
文件夹里有哪些文件? - Cerberuscargo build
返回相同的错误,而我在src
中唯一拥有的文件是 GuessingGame.rs。 - ThatVibingCat