Is there any way to rename a Cargo project?
Under Linux this is fairly strait forward:
- go to the directory where your project is located e.g. if your project was called hello_world in a folder named rust then go to the rust folder
pi@raspberrypi:~/workspace/rust/hello_world $ cd ..
- from there you can rename the project by
- mv [current name of the project] [name you want] to move. E.g. if I wanted to rename it from hello_world to hello_rust I would type
mv hello_world/ hello_rust/
to rename the folder. - now you only have to change the name in your Cargo.toml file:
pi@raspberrypi:~/workspace/rust $ cd hello_rust/
pi@raspberrypi:~/workspace/rust/hello_rust $ geany Cargo.toml
- (I am using geany but you can use whatever text editor you like)
- in Cargo.toml in the second line change
name = "hello_world"
toname = "hello_rust"
- mv [current name of the project] [name you want] to move. E.g. if I wanted to rename it from hello_world to hello_rust I would type
Hope that this might help someone in the future
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.