| Crates.io | rashmin_rustbook_ch14 |
| lib.rs | rashmin_rustbook_ch14 |
| version | 0.1.2 |
| created_at | 2025-12-25 15:18:23.851625+00 |
| updated_at | 2025-12-25 15:25:53.129914+00 |
| description | Rust Programming Language Book - Chapter 14 Code |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2004647 |
| size | 5,411 |
This chapter covers advanced Cargo features and publishing crates to crates.io, the Rust community's package registry.
cargo doccargo installmycrateThe mycrate directory contains a simple example library crate that demonstrates:
cargo doc to generate HTML documentationTo build the crate:
cd mycrate
cargo build
To run the binary (which just prints "Hello, world!"):
cargo run
To generate documentation:
cargo doc --open
This will open the generated documentation in your browser.
Note: Publishing requires a crates.io account and API token. The crate has already been published as rashmin_rustbook_ch14.
To publish your own version:
cargo login with your tokenCargo.tomlcargo publishThe crate provides simple arithmetic functions:
add_one(x: i32) -> i32: Adds 1 to the given numberadd_two(x: i32) -> i32: Adds 2 to the given numberadd_custom(x: i32, value: i32) -> i32: Adds a custom value (panics if value is negative)Try the following:
Cargo.toml