What Is Rust Doing Behind The Curtains? - FOSDEM

2y ago
9 Views
2 Downloads
7.12 MB
51 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Laura Ramon
Transcription

What Is Rust DoingBehind the Curtains?

Hi! I amMatthias EndlerYou might know me from.My YouTube channel!My Blog!!2Not at all!

Hotel Search Platform 2.5m Hotels/Accommodations IT departments in Düsseldorf, Leipzig, Palma, Amsterdam Java, Kotlin, Go, PHP, Python (, Rust?) tech.trivago.com

Why should I care?!4

Rust is a systems programming language that runsblazingly fast, prevents segfaults, and guarantees threadsafety. It aims to bring modern language design and anadvanced type system to systems programming. Rustdoes not use a garbage collector, using advanced staticanalysis to provide deterministic drops instead.

Rust is a systems programming language that runsblazingly fast, prevents segfaults, and guarantees threadsafety. It aims to bring modern language design and anadvanced type system to systems programming. Rustdoes not use a garbage collector, using advanced staticanalysis to provide deterministic drops instead.

Empowering everyoneto build reliable andefficient software.

Be curious.Try crazy things.Don't be afraid.

!9

Being curious is an amazing trait!We should embrace it,and help people be curious.Pascal Hertleif –Rust’s approach of getting things right

Julia Evans

Why's Poignant Guide to Ruby

The Rust Compiler!14

RUST ionMIROptimizationLLVM IROptimizationMACHINE CODE!15

RUST tionMIRBorrow-checkingOptimizationLLVM IROptimizationMACHINE CODE!16

Desugaring.Candy designed by Freepik, Vegetables by Macrovector

At last.Code examples!!18

Example 1

fn main() {}

#[macro use]extern crate std;#[prelude import]use std::prelude::v1::*;fn main() {}

Types: std::boxed::Boxstd::option::Option::{self, Some, None}std::result::Result::{self, Ok, Err}std::string::String;std::vec::VecTraits: rtialEq, PartialOrd, Eq, Ord }std::convert::{AsRef, AsMut, Into, terator, ExactSizeIterator}std::iter::{Iterator, Extend, IntoIterator}std::marker::{Copy, Send, Sized, Sync}std::ops::{Drop, Fn, FnMut, ringFunctions: std::mem::drop

Types:Box, Option, Result, String, VecTraits:PartialEq, PartialOrd, Eq, OrdOrdering thingsAsRef, AsMut, Into, From, ToOwned, Clone, ToStringDefaultDefault valuesConverting thingsDoubleEndedIterator, ExactSizeIteratorIterator, Extend, IntoIteratorCopy, Send, Sized, SyncDrop, Fn, FnMut, FnOnceSliceConcatExtIterationMarker traitsCalling/Dropping objectsConcatenate objects(like strings or vectors)

Example 2Ranges

for i in 0.3 {// do something with i}

let range 0.3;for i in range {// do something with i}

let range Range {0, 3};for i in range {// do something with i}

let range Range {0, 3};for i in range {// do something with i}

use std::ops::Range;let range Range { start: 0, end: 3 };for i in range {// do something with i}

use std::iter::IntoIterator;use std::ops::Range;let range Range { start: 0, end: 3 };let mut iter IntoIterator::into iter(range);while let Some(i) iter.next() {// do something with i}

use std::iter::IntoIterator;use std::ops::Range;let range Range { start: 0, end: 3 };let mut iter IntoIterator::into iter(range);loop {match iter.next() {Some(i) { /* use i */ },None break,}}

cargo inspect

cargo-install cargo-inspectcargo inspect foo.rs!33

Example 3Ranges - Part II

for i in 0. 3 {// do something with i}

use std::iter::IntoIterator;use std::ops::RangeInclusive;let range RangeInclusive::new(0, 3);let mut iter IntoIterator::into iter(range);loop {match iter.next() {Some(i) { /* use i */ },None break,}}

cargo inspect --diff foo.rs,bar.rs!37

Example 4Opening Files

use std::fs::File;use std::io::Error;fn main() - Result (), Error {let f File::open("file.txt")?;Ok(())}

use std::fs::File;use std::io::Error;fn main() - Result (), Error {let f match File::open("file.txt") {Ok(file) file,Err(err) return Err(err),};Ok(())}

use std::fs::File;use std::io::Error;use std::convert::From;fn main() - Result (), Error {let f match File::open("file.txt") {Ok(file) file,Err(err) return Err(From::from(err)),};Ok(())}

cargo-inspect-vscode

More cargo tools! cargo-expandcargo-asmcargo-bloat!43

Rust Playground!44

play.rust-lang.org!45

Compiler Explorer!46

godbolt.org!47

Lessons Learned Rust allows for lots of syntactic sugar It's good to be reminded about that sometimes Tools help us understand what's going onbehind the curtains.!48

Now go and build cool things!!49

Credits Stage background from freepik.com designed bystarline Lucy with a Rocket engine Rustlang MIR documentation Rust compiler guide!51

Why's Poignant Guide to Ruby. The Rust Compiler!14!15 RUST SOURCE HIR . Rust compiler guide

Related Documents:

Altitude, rainfall and harvest effects on the coffee rust progress curve Avelino et al., 2002, modificado de Avelino et al., 1990 (Chiapas, México) e f leaves th rust Time Month/year l) Harvest period 460 m 730 m 1100 m More rust at low altitude More rainfall does not necessarily mean more rust (spore washing) Coffee rust peak at the end of the

In this paper, we identify dynamic trait objects as an essential language feature for Rust verification tools to tackle in order to enable use on large, real-world Rust projects. Our contributions are as follows: We describe the Kani Rust Verifier, an open-source bit-precise symbolic model checker for Rust programs. We show that

Autentico RUST IN A JAR is a part of the creative powder range It consists of three highly pigmented powders to create truly stunning rust effects on walls, furniture, lamp bases, candle holders, without the need of using dangerous corrosive ingredients. RUST IN A JAR can be

Rust “Rust is a language for systems programming.” Jim Blandy & Jason Orendorff, Programming Rust “Systems programming is for: Code

5 *Xylol-wetordrypaint. Mineralspirits-wetpaint. RUST-OLEUM STOPS RUST Product Touch-Up SprayTips Spray-Rust

Additional copies of Doing Business 2010: Reforming through Difficult Times, Doing Business 2009, Doing Business 2008, Doing Business 2007: How to Reform, Doing Business in 2006: Creating Jobs, Doing Business in 2005: Removing Obstacles to Growth and Doing Business in 2004: Understanding Regulations may be purchased at www.doingbusiness.org.

Machinery Dark Gray (ANSI-49) Blue/Gray Machinery Blue Gray (ANSI-24) OSHA Black OSHA White Flat White Clear Gloss Semi-Flat Black Max Flat Black Rebar Green High-Heat Aluminum High-Heat Black Fluorescent Orange Fluorescent Red Fluorescent Electric Green Green Rust Inhibitor Red Oxide Rust Control Red Oxide Sandable Gray Rust Control Light Gray .

PROGRAMI I STUDIMIT Administrim Publik ID MATURE Piket e grumbulluara 201519800030 9.39 201418500072 9.08 201418300019 8.97 201418300020 8.78 201418500152 8.69 201461700004 8.67 201418200012 8.60 201418200004 8.54 201418200002 8.51 201418300004 8.43 201418200005 8.43 201418500092 8.40 201418500015 8.37 201418500131 8.32 203343900033 8.30 201418500021 8.21 201519400032 8.06 201417600080 8.04 .