Crates.io | lrk |
lib.rs | lrk |
version | 0.1.3 |
source | src |
created_at | 2023-02-08 14:25:05.303697 |
updated_at | 2023-02-08 23:08:19.155786 |
description | learning rust |
homepage | https://github.com/kagemeka/learn-rust#readme |
repository | https://github.com/kagemeka/learn-rust |
max_upload_size | |
id | 779673 |
size | 31,542 |
learn-rust is a package. a crate is a binary or library. a package can have a library crate (lib.rs) and multiple binary crates (main.rs, bin/*.rs, bin/*/main.rs). (need at least one library or binary crate. a workspace can have multiple packages as members.
https://doc.rust-lang.org/stable/cargo/
https://doc.rust-lang.org/stable/cargo/reference/config.html https://doc.rust-lang.org/stable/cargo/reference/environment-variables.html
cargo init --bin # for binary(executable) crate
cargo init --lib # for library crate
src/main.rs
cargo run
src/bin
directory.src/main.rs
src/bin/another_executable.rs
src/bin/multi_files_executable/main.rs
default-run
in Cargo.toml
cargo run
without --bin
option.cargo run --bin learn-rust # to run main.rs
cargo run --bin another_executable # to run bin/another_executable.rs
cargo run --bin multi_files_executable
# to run bin/multi_files_executable/main.rs
cargo run # = cargo run --bin learn-rust (when default-run = learn-rust)
cargo run --release
cargo new --lib another_crate
https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
cargo doc --open
cargo clean
cargo check
https://doc.rust-lang.org/cargo/reference/publishing.html
cargo login <token> # only once
cargo publish