rlb01_hello-cargo

Crates.iorlb01_hello-cargo
lib.rsrlb01_hello-cargo
version0.2.0
sourcesrc
created_at2023-12-12 01:49:13.699177
updated_at2023-12-12 02:08:16.597455
descriptionA hello world program in Rust
homepagehttps://github.com/poneding/learning-rust/tree/master/rust-lang-book/rlb01_hello-cargo
repositoryhttps://github.com/poneding/learning-rust/tree/master/rust-lang-book/rlb01_hello-cargo
max_upload_size
id1065757
size3,226
Pone Ding (poneding)

documentation

README

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
Commit count: 0

cargo fmt