Reputation: 6976
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?
Upvotes: 28
Views: 33563
Reputation: 71
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
Upvotes: 6
Reputation: 98388
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.
Upvotes: 26