gpt4 book ai didi

rust - 即使src/main.rs可用, cargo 也不会生成

转载 作者:行者123 更新时间:2023-12-03 11:45:43 28 4
gpt4 key购买 nike

我正在尝试使用 cargo build 。以下是项目结构

tree
.
├── Cargo.toml
└── src
└── main.rs

Cargo.toml的内容
[package]
name = "server"
version = "0.1.0"
authors = ["Lokanath Mohanty <lokanath.mohanty@adcolony.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

src/main.rs的内容
use std::io::{ErrorKind, Read, Write};
use std::net::TcpListener;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;

const LOCAL_IP: &str = "127.0.0.1:6001";
const MSG_SIZE: usize = 32;


fn main() {
...
}

我收到以下错误-
error: failed to parse manifest at `/home/debashishc/Downloads/Cargo.toml`

Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present

最佳答案

Cargo查找并尝试parse Cargo.toml in parent directories,因为它检查您的箱子是否是较大workspace的一部分。

从父目录中删除损坏的Cargo.toml。或者,将您的 crate 的Cargo.toml用作工作区,以阻止 cargo 进一步搜索。

关于rust - 即使src/main.rs可用, cargo 也不会生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61134990/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com