Rust – Programming Language – A brief tutorial by



Rust – Programming Language – A brief tutorial by

0 0


rust-tutorial

Nothing to see here. Get along.

On Github migulorama / rust-tutorial

Rust

Programming Language

A brief tutorial by

  • Luís Cleto - ei11077
  • Miguel Marques - ei11099

Introduction

What is Rust?

“Rust is a systems programming language that runs blazingly fast, prevents almost all crashes*, and eliminates data races.”

...

* In theory. Rust is a work-in-progress and may do anything it likes up to and including eating your laundry.

My first Rust "program"

Features

Types

Pattern Matching

Traits

Generics

Memory Safety

Rust's compiler statically determines when you need to allocate or deallocate memory, and inserts those calls itself.

“To err is to be human, but compilers never forget.”

Ownership

Borrowing

There is a ‘data race’ when two or more pointers access the same memory location at the same time, where at least one of them is writing, and the operations are not synchronized.

Borrowing - Rules

  • A borrow must last for a smaller scope than the owner.
  • You must have:
    • 0 or more references (&T) to a resource.
    • Exactly 1 mutable reference (&mut T)

Borrowing - Example

Mutability

Other Features

  • Lifetimes
  • Macros
  • Compiler Plugins
  • Efficient C Bindings
  • Conditional Compilation
  • Unsafe Keyword

Paradigms

Functional

Imperative

Others

  • Object Oriented
  • Concurrent Actor

Tools

Cargo

Rust's Package Manager

crates.io

Racer

Rust Auto-Complete-er

github.com/phildawes/racer

RustDT

Eclipse plugin

rustdt.github.io

Why Rust?

  • Still growing (with Mozilla's help)
  • Speed comparable to C/C++
  • Safe
  • Versatile
  • Strong support for concurrency

References

Questions?

Rust Programming Language