Rust in 100 seconds, potentially and beyond!

Overview

Rust in 100 seconds

Watch the Rust in 100 Seconds Video.

Article: What is Rust, and why is it so popular?

What is Rust?

Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.

Rust’s rich type system and ownership model guarantee memory-safety and thread-safety — enabling you to eliminate many classes of bugs at compile-time.

Rust has great documentation, a friendly compiler with useful error messages, and top-notch tooling — an integrated package manager and build tool, smart multi-editor support with auto-completion and type inspections, an auto-formatter, and more.

"My biggest compliment to Rust is that it's boring, and this is an amazing compliment."

– Chris Dickinson, Engineer at npm, Inc

Did you know?

  • Rust developers are known as "Rustaceans"
  • Firefox, Dropbox, and Cloudflare use Rust!
  • Rust is installed and managed by a tool called rustup
  • Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time

Documentation

Official site: rust-lang.org

Github: github.com/rust-lang

Code formatting: github.com/rust-lang/rustfmt

Crates: crates.io

VS Code extensions:

Installation

Linux and macOS

curl https://sh.rustup.rs -sSf | sh

Windows

Follow the installation steps: forge.rust-lang.org/infra/other-installation-methods

Add Rust to your system PATH

In the Rust development environment, all tools are installed to the ~/.cargo/bin directory, and this is where you will find the Rust toolchain, including rustc, cargo, and rustup.

Note:

Is customary for Rust developers to include this directory in their PATH environment variable. During installation rustup will attempt to configure the PATH. Because of differences between platforms, command shells, and bugs in rustup, the modifications to PATH may not take effect until the terminal is restarted, the user is logged out, or it may not succeed at all

Options

  1. Restart your terminal and/or restart your computer

-or-

  1. Add Rust to PATH manually:
source $HOME/.cargo/env
  1. Add to your bash/zsh profile:
export PATH="$HOME/.cargo/bin:$PATH"

Toolchain management with rustup

Update

rustup update

Uninstall

rustup self uninstall

Troubleshooting

rustc --version
# rustc x.y.z (abcabcabc yyyy-mm-dd)
# If this fails, check your $PATH configuration

Create a new project with Cargo

What is Cargo?

Cargo is a package manager that is equivalent to npm or pub, and comes built in with Rust.

Get started

  1. Create a new project:
cargo new project_name # Scaffold a new project
cd project_name # Open the project folder
code . # Open VS Code (or text editor of choice)

Project anatomy

File Structure

project_name
├── Cargo.toml
├── .gitignore
└── src
    └── main.rs

Cargo.toml

Equivalent to pubspec.yaml in Dart/Flutter or package.json in JS/TS

[package]
name = "project_name"
version = "0.1.0"
edition = "2018"

[dependencies]
# Dependencies (crates) go here

main.rs

Equivalent to index.js, main.dart, etc.

// Main application
fn main() {
    // Print to console
    println!("Hello, world!");
}

Build and run a Cargo project

Builds update the file structure accordingly:

project_name
...
├── Cargo.lock
└── target
    ├── debug
    └── release

Debug build

cargo build

Release build

cargo build --release

Run it

Builds with optimizations for client delivery

cargo run

  Compiling rust_in_100 v0.1.0 (/Users/klutch/Desktop/FireshipRust/rust_in_100)
      Finished dev [unoptimized + debuginfo] target(s) in 4.52s
       Running `target/debug/rust_in_100`
Hello, world!

Check

cargo check # Verify that it compiles without building
You might also like...
A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models you subscribe to on Onlyfans.

OF-notifier A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models

Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed.

integra8 Integra8 rust integration test framework Rust with a focus on productivity, extensibility, and speed. | This repo is in a "work in progress"

TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Rust implementation of Andrej Karpathy's micrograd for purposes of learning both ML and Rust.

micrograd_rs Rust implementation of Andrej Karpathy's micrograd for purposes of learning both ML and Rust. Main takeaways Basically the same takeaways

:crab: Small exercises to get you used to reading and writing Rust code!
:crab: Small exercises to get you used to reading and writing Rust code!

rustlings 🦀 ❤️ Greetings and welcome to rustlings. This project contains small exercises to get you used to reading and writing Rust code. This inclu

A catalogue of Rust design patterns, anti-patterns and idioms

Rust Design Patterns An open source book about design patterns and idioms in the Rust programming language that you can read here. Contributing You ar

Simple and performant hot-reloading for Rust

reloady Simple, performant hot-reloading for Rust. Requires Rust nightly and only works on Linux for now. installing CLI To install the CLI helper car

Owner
Fireship
Fireship
In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang.

Learn Rust What is this? In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang. This is usef

Domagoj Ratko 5 Nov 5, 2022
A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32 architectures going step-by-step into the world of reverse engineering Rust from scratch.

FREE Reverse Engineering Self-Study Course HERE Hacking Rust A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32

Kevin Thomas 98 Jun 21, 2023
An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

null 2 Oct 24, 2021
Fast and simple datetime, date, time and duration parsing for rust.

speedate Fast and simple datetime, date, time and duration parsing for rust. speedate is a lax† RFC 3339 date and time parser, in other words, it pars

Samuel Colvin 43 Nov 25, 2022
A simpler and 5x faster alternative to HashMap in Rust, which doesn't use hashing and doesn't use heap

At least 5x faster alternative of HashMap, for very small maps. It is also faster than FxHashMap, hashbrown, ArrayMap, and nohash-hasher. The smaller

Yegor Bugayenko 12 Apr 19, 2023
Safe, efficient, and ergonomic bindings to Wolfram LibraryLink and the Wolfram Language

wolfram-library-link Bindings to the Wolfram LibraryLink interface, making it possible to call Rust code from the Wolfram Language. This library is us

Wolfram Research, Inc. 28 Dec 6, 2022
This blog provides detailed status updates and useful information about Theseus OS and its development

The Theseus OS Blog This blog provides detailed status updates and useful information about Theseus OS and its development. Attribution This blog was

Theseus OS 1 Apr 14, 2022
Omeglib, a portmanteau of "omegle" and "library", is a crate for interacting with omegle, simply and asynchronously

Omeglib, a portmanteau of "omegle" and "library", is a crate for interacting with omegle, simply and asynchronously. It is intended to suit one's every requirement regarding chat on omegle.

null 1 May 25, 2022
A tool and library to losslessly join multiple .mp4 files shot with same camera and settings

mp4-merge A tool and library to losslessly join multiple .mp4 files shot with same camera and settings. This is useful to merge multiple files that ar

Gyroflow 7 Jan 2, 2023