Linux 有没有办法重命名Cargo项目?
我使用:Linux 有没有办法重命名Cargo项目?,linux,rust,rust-cargo,Linux,Rust,Rust Cargo,我使用:cargo new projectname--bin创建了一个项目。 如何将projectname更改为其他名称 我检查了房间和房间。我还跑了: 货物帮助 货物-列表 mancargo 在元数据文件(Cargo.toml、Cargo.lock等)中,有“name”和“path”。我想我可以手动更改它们,但我不知道这是否会破坏任何东西 最好的方法是什么?我认为您应该手动更改它。其实没那么难 我运行以下代码: $cargo新蓝精灵--bin 创建二进制(应用程序)`smurf`项目 $c
cargo new projectname--bin
创建了一个项目。
如何将projectname
更改为其他名称
我检查了房间和房间。我还跑了:
货物帮助
货物-列表
mancargo
最好的方法是什么?我认为您应该手动更改它。其实没那么难 我运行以下代码:
$cargo新蓝精灵--bin
创建二进制(应用程序)`smurf`项目
$cd蓝精灵/
蓝精灵$cargo-build
....
蓝精灵$grep-rl蓝精灵。
./target/debug/smurf.d
/目标/调试/蓝精灵
./target/debug/.fingerprint/smurf-35f069edf7faaa12/bin-smurf-35f069edf7faaa12.json
./target/debug/.fingerprint/smurf-35f069edf7faaa12/dep-bin-smurf-35f069edf7faaa12
./target/debug/deps/smurf-35f069edf7faaa12
/货物锁
/Cargo.toml
可以从所有这些文件中删除整个目标。.lock
文件也可以删除。还有Cargo.toml
。。。你可以编辑它
我试着只更改了Cargo.toml
,一切正常。但是,在target
中您最终会得到无用的文件,因此我建议您还是删除这些文件。在Linux下,这是相当困难的:
- 转到项目所在的目录,例如,如果项目在名为rust的文件夹中被称为hello_world,则转到rust文件夹
pi@raspberrypi:~/workspace/rust/hello\u world$cd..
- 从那里,您可以通过以下方式重命名项目:
- mv[项目的当前名称][您想要的名称]要移动。例如,如果我想将其从hello_world重命名为hello_rust,我会键入
mv hello\u world/hello\u rust/
重命名文件夹
- 现在,您只需更改Cargo.toml文件中的名称:
pi@raspberrypi:~/workspace/rust$cd hello\u rust/
pi@raspberrypi:~/workspace/rust/hello\u rust$geany Cargo.toml
- (我正在使用geany,但您可以使用您喜欢的任何文本编辑器)
- 第二行中的in Cargo.toml更改
name=“hello\u world”
至name=“hello\u rust”
希望这可能对将来的人有所帮助Sweet!这看起来很轻松,我想这必须在Cargo团队本机实现之前完成。Cargo clean将删除整个目标目录。见: