#hello-world #world #hello

app rlb01_hello-cargo

A hello world program in Rust

3 unstable releases

0.2.0 Dec 12, 2023
0.1.1 Dec 12, 2023
0.1.0 Dec 12, 2023

#81 in #hello

MIT/Apache

4KB

Rust cargo 管理工具

创建项目

cargo new rlb01_hello-cargo
cd rlb01_hello-cargo

可以使用 cargo new --vcs git rlb01_hello-cargo 创建项目并初始化 git 仓库,它将自动创建一个 .gitignore 文件。

编译项目

cargo build

# 编译之后将在 target/debug 目录下生成可执行文件
# 可以通过以下命令运行
./target/debug/rlb01_hello-cargo

运行项目

cargo run

检测项目是否可以编译

cargo check

安装可执行文件

cargo install --path .

发布项目

发布到 crates.io,需要注册账号。

并且,需要在 Cargo.toml 中添加部分内容,例如作者、描述、许可证必要信息以及其他信息:

[package]
name = "rlb01_hello-cargo"
version = "0.2.0"
edition = "2021"
authors = ["Pone Ding <poneding@gmail.com>"]
description = "A hello world program in Rust"
license = "MIT OR Apache-2.0"
readme = "README.md"
keywords = ["hello", "world"]
categories = ["hello-world"]
repository = "https://github.com/poneding/learning-rust/tree/master/rust-lang-book/rlb01_hello-cargo"
homepage = "https://github.com/poneding/learning-rust/tree/master/rust-lang-book/rlb01_hello-cargo"
cargo publish

# 忽略未提交的更改
cargo publish --allow-dirty

No runtime deps