Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Install Rust

Code Block
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

...

Code Block
themeEmacs
./main
Code Block
Hello, world!


Using the Package Manager

Create a project using Cargo

Code Block
themeEmacs
cargo new hello_cargo
Code Block
    Creating binary (application) `hello_cargo` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

This command creates a folder with the name of the new project containing a src directory and the dependency file called Cargo.toml.


Code Block
hello_cargo
├── .git
│   ├── HEAD
│   ├── config
│   ├── description
│   ├── hooks
│   │   └── README.sample
│   ├── info
│   │   └── exclude
│   ├── objects
│   │   ├── info
│   │   └── pack
│   └── refs
│       ├── heads
│       └── tags
├── .gitignore
├── Cargo.toml
└── src
    └── main.rs

It has also initialized a new Git repository along with a .gitignore file. Git files won’t be generated if you run cargo new within an existing Git repository; you can override this behavior by using cargo new --vcs=git.


Cargo.toml

Code Block
[package]
name = "hello_cargo"
version = "0.1.0"
edition = "2021"

[dependencies]                



References

ReferenceURL
The Rust Programming Languagehttps://doc.rust-lang.org/book/title-page.html