Professional Documents
Culture Documents
## Installation
- install rust `curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh`
(this also installs Cargo)
- install linker `xcode-select --install`
## Hello World
```rust
fn main() {
println!("Hello, world!");
}
```
- install cargo
- use `cargo --version` if cargo was not installed
- create project with cargo
- `cargo new hello_cargo`
- this generates
- `Cargo.toml`
```rust
[package] - this is a headline
name = "hello_cargo"
version = "0.1.0"
edition = "2021"
- `cargo build`
- `cargo run` or `./target/debug/hello_cargo`
- the result is stored in `target/debug` directory
- `cargo check` - compiles, but doesn't create an executable
- faster than build
- `cargo build --release` - for release
- creates executable with optimizations to run faster, but build and
compilation is long
- the result is stored in `target/release` directory