mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-23 03:56:23 +00:00
66 lines
778 B
Markdown
66 lines
778 B
Markdown
|
---
|
||
|
id: 33187ecc-81fd-4136-ad10-b69e8463bd6d
|
||
|
title: Rust tooling
|
||
|
---
|
||
|
|
||
|
# Rustc
|
||
|
|
||
|
Rustc handles Rust compilation `rustc main.rs`
|
||
|
|
||
|
# Cargo
|
||
|
|
||
|
Cargo is Rust's build system and package manager
|
||
|
|
||
|
## Cargo commands
|
||
|
|
||
|
### Create project
|
||
|
|
||
|
``` shell
|
||
|
cargo new hello_cargo
|
||
|
```
|
||
|
|
||
|
### Build project
|
||
|
|
||
|
``` shell
|
||
|
cargo build
|
||
|
```
|
||
|
|
||
|
### Build & run project
|
||
|
|
||
|
``` shell
|
||
|
cargo run
|
||
|
```
|
||
|
|
||
|
1. Backtrace
|
||
|
|
||
|
When you want to see an error backtrace set the `RUST_BACKTRACE`
|
||
|
environment variable:
|
||
|
|
||
|
``` shell
|
||
|
RUST_BACKTRACE=1 cargo run
|
||
|
```
|
||
|
|
||
|
### Check code
|
||
|
|
||
|
``` shell
|
||
|
cargo check
|
||
|
```
|
||
|
|
||
|
### Build for release
|
||
|
|
||
|
``` shell
|
||
|
cargo build --release
|
||
|
```
|
||
|
|
||
|
## Cargo.toml
|
||
|
|
||
|
``` toml
|
||
|
[package]
|
||
|
name = "hello_cargo"
|
||
|
version = "0.1.0"
|
||
|
authors = ["Your Name <you@example.com>"]
|
||
|
edition = "2018"
|
||
|
|
||
|
[dependencies]
|
||
|
```
|