I created a project using: cargo new projectname --bin
.
How do I change projectname
to some other name?
I checked the man page and the Cargo documentation. I also ran:
cargo help
cargo --list
man cargo
In the metadata files (Cargo.toml, Cargo.lock, ...), there is "name" and "path". I suppose I could change them manually, but I don't know if that would break anything.
What would be the best way to do this?
Project cargo is a type of cargo that is oversized, typically high value and out of gauge cargo (OOG), requiring special equipment such as cranes, forklifts, trucks or tools to move. This type of cargo is transported by utilizing specialized vessels, train wagons, trucks or aircrafts.
Moving project cargo also requires proper appreciation for safety, an eye for detail, and a systematic plan that considers various logistical challenges such as road, weather, availability and transportation conditions. Project cargo is found in a wide variety of applications.
This type of cargo is transported by utilizing specialized vessels, train wagons, trucks or aircrafts.
I think that you should change it manually. Not so difficult, really.
I run this code:
$ cargo new smurf --bin
Created binary (application) `smurf` project
$ cd smurf/
smurf$ cargo build
....
smurf$ grep -rl smurf .
./target/debug/smurf.d
./target/debug/smurf
./target/debug/.fingerprint/smurf-35f069edf7faaa12/bin-smurf-35f069edf7faaa12.json
./target/debug/.fingerprint/smurf-35f069edf7faaa12/dep-bin-smurf-35f069edf7faaa12
./target/debug/deps/smurf-35f069edf7faaa12
./Cargo.lock
./Cargo.toml
From all these files, the whole target
may be just deleted. The .lock
file can also be deleted. And the Cargo.toml
... well you can just edit it.
I tried changing only the Cargo.toml
and all just works. However you end up with useless files in target
so I recommend deleting those anyway.
Under Linux this is fairly strait forward:
pi@raspberrypi:~/workspace/rust/hello_world $ cd ..
mv hello_world/ hello_rust/
to rename the folder.pi@raspberrypi:~/workspace/rust $ cd hello_rust/
pi@raspberrypi:~/workspace/rust/hello_rust $ geany Cargo.toml
name = "hello_world"
to name = "hello_rust"
Hope that this might help someone in the future
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With