LCM Logo
Programming

Rust

Installation

We recommend using rustup to install Rust.

Install rustup

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

Update using rustup

You can update Rust to the latest version using rustup:

rustup update

Create a new cargo project

For a binary, i.e., an executable program:

Create a new directory named my_project and initialize a new Cargo project inside it:

cargo new my_project

Alternatively, you can initialize a new Cargo project in an existing directory:

mkdir my_project
cd my_project
cargo init

For a library:

cargo new my_library --lib

or

mkdir my_library
cd my_library
cargo init --lib
  • cargo new pkg-name creates a new directory.
  • cargo init initializes a new project in the current directory.

On this page