Introduction
This book aims to speed up development by helping the developer add some (basic, but useful) functionality to Rust projects easily.
The idea is to provide something that can be mostly copy pasted and provide links to additional resource links to highly relevant references and tutorials.
Currently this lives in: GitHub. Pull requests are welcome!
By magic of continous integration, static pages are built to GitHub Pages - You might be here already!
Useful crates
Collections
Crates that are likely be included in snippets
Adding Command-Line Interface
Adds cli functionality.
Cargo.toml
Default features for clap, sans color.
cargo add clap --no-default-features -F derive,cargo,error-context,help,std,suggestions,usage
main.rs
mod cli;
use cli::{Cli, Parser};
fn main() {
let args = Cli::parse();
...
}
cli.rs
pub use clap::Parser;
use std::path::PathBuf;
/// Amazing command-line interface
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Cli {
/// Process file
pub path: PathBuf,
}
More information
Contributing
If you wish to contribute, at minimum do the following.
Install mdbook
Self-explanatory step! =)
cargo install mdbook
During development
Easiest is to develop using live web server which refreshes the view automatically. This helps you to keep the edited page visible to make it look somewhat standardized as well.
mdbook serve
Before pull request
As the CI pipeline tests all the Rust examples, they need to be either valid or ignored.
Check that all Rust blocks are tagged either "rust" or "rust,ignore", whichever makes more sense. Do not try to make it testable example if it doesn't make sense. Prioritise user ease of copy & paste!
mdbook test