Is there a way to rename the Cargo project?

I created a project using: cargo new projectname --bin

. How can I change projectname

to another name?

I checked the man page and Truck Documentation . I also ran:

  • cargo help

  • cargo --list

  • man cargo

Metadata files (Cargo.toml, Cargo.lock, ...) have a "name" and a "path". I guess I can change them manually, but I don't know if that might break something.

What would be the best way to do this?

+3


source to share


1 answer


I think you have to change it manually. It's actually not that hard.

I am running 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, everything target

can be simply deleted. The file .lock

can also be deleted. And Cargo.toml

... well, you can just edit it.

I tried to change only Cargo.toml

and everything just works. However, you end up with useless files in target

, so I recommend deleting them anyway.

+3


source







All Articles