Closed
Description
Problem
cargo init
has a nice feature, in that if the file foo.rs
exists in the directory foo
that is being initialized, no src
directory will be created and instead name = "foo"
and path = "foo.rs"
will be placed in Cargo.toml
.
Unfortunately, cargo init --bin
still produces a lib
crate in this case.
Steps
mkdir foo
cd foo
touch foo.rs
cargo init --bin
The resulting Cargo.toml
is
[package]
name = "foo"
version = "0.1.0"
authors = ["Me <[email protected]>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
[lib]
name = "foo"
path = "foo.rs"
I would strongly prefer getting [[bin]]
instead of [lib]
here.
Notes
Output of cargo version
: cargo 1.51.0 (43b129a20 2021-03-16)