Total Pageviews

Sunday 21 April 2024

learn-rust

Notes and demo code related to Rust learning

cargo usage

Version:

cargo version

Init workspace

Create and edit Cargo.toml

[workspace]

members = [
    "basics",
    "value_demo",
    "persist_data",
    "scrape_url",
    "httpie"
]

Init project

cargo new <project-name>
cargo new <lib-name> --lib

Add dependency

Edit Cargo.toml:

[dependencies]
anyhow = "1"

cargo-edit:

cargo install cargo-edit
cargo add anyhow colored jsonxf mime

Run project:

cargo run

Build project:

cargo build
cargo build --quiet
cargo build --release

Test project:

cargo test
from https://github.com/pseudoyu/learn-rust 

No comments:

Post a Comment