rust - 即使 src/main.rs 可用, cargo 也不会构建
问题描述
我正在尝试使用货物构建来构建。以下是项目结构
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 会在父目录中查找并尝试解析Cargo.toml
,因为它会检查您的 crate 是否是更大工作空间的一部分。
Cargo.toml
从父目录中删除损坏的。或者,将您的板条箱Cargo.toml
设为工作区,以阻止货物进一步搜索。