rust first step
Table of Contents
installation
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Cargo
Cargo: the Rust build tool and package manager
When you install Rustup you’ll also get the latest stable version of the Rust build tool and package manager, also known as Cargo. Cargo does lots of things:
- build your project with
cargo build
- run your project with
cargo run
- test your project with
cargo test
- build documentation for your project with
cargo doc
- publish a library to crates.io with
cargo publish
To test that you have Rust and Cargo installed, you can run this in your terminal of choice:
cargo --version
Example
fn main() {
println!("Hello, world!");
}
- build
$ rustc main.rs
$ ./main
Hello, world!
or
cargo new hello_cargo
cd hello_cargo
cargo build
cargo run
Comments |0|
Category: 似水流年