rust: gourd boggling
I was writing some companion notes as I was following along with the rust book. I found myself appending screenshot after progressively wowwier screenshot as I played around with cargo doc --open
cargo = rust's build tool & package manager
gives you the following commands
cargo build
cargo test
cargo doc
(!)
cargo run
(compiles & runs in one step)
cargo publish
(publishes to <crates.io>)
for global installation of fmt & linting tools:
rustup component add rustfmt ; rustup component add clippy
in the lil starter project I used the rand
random number generator
use rand::Rng
// etc
let secret_num = rand::thread_rng()
.gen_range(1, 101);
cargo doc --open
will build docs provided by all ur local dependencies; if u are using rand::Rng
, you can call the former and click on rand
to find out more functionality contained in the crate
then clicking on the methods will reveal trait implementations, methods, etc.
wowwie 🆗 !
p.s. there are gorgeous examples for each method 😱
/ omg it will even show you the source code for any method :gagged:
With the help of cargo doc
I quickly was able to peek at other methods available to a pkg, see example uses, see the source code for each, and add them to my own project.
The only docs I've seen that are this good/practically usable are Haskell's (jk!! :smiling:) Ramda's (opens new window). The diff? Cargo generates them on demand for locally installed crates.
:wow: