Tutorial by Examples

Library cargo new my-library This creates a new directory called my-library containing the cargo config file and a source directory containing a single Rust source file: my-library/Cargo.toml my-library/src/lib.rs These two files will already contain the basic skeleton of a library, such th...
Debug cargo build Release Building with the --release flag enables certain compiler optimizations that aren't done when building a debug build. This makes the code run faster, but makes the compile time a bit longer too. For optimal performance, this command should be used once a release build ...
Basic Usage cargo test Show program output cargo test -- --nocapture Run specific example cargo test test_name
This is a shell session showing how to create a "Hello world" program and run it with Cargo: $ cargo new hello --bin $ cd hello $ cargo run Compiling hello v0.1.0 (file:///home/rust/hello) Running `target/debug/hello` Hello, world! After doing this, you can edit the progra...
To publish a crate on crates.io, you must log in with Cargo (see 'Connecting Cargo to a Crates.io Account'). You can package and publish your crate with the following commands: cargo package cargo publish Any errors in your Cargo.toml file will be highlighted during this process. You should en...
Accounts on crates.io are created by logging in with GitHub; you cannot sign up with any other method. To connect your GitHub account to crates.io, click the 'Login with GitHub' button in the top menu bar and authorise crates.io to access your account. This will then log you in to crates.io, assumi...

Page 1 of 1