Rust Latam 2019

Me

Workshops

Learning WebAssembly and Rust

Talks Day

Opening Keynote

Niko Matsakis

História do Rust

"Rust is Open"

Defense Against The Wrong Logic: Proactive Rust Coding

Michael Gattozzi

type é para áliases.


type Farenheit = i32;
type Celsius = i32;

fn is_it_hot(t: Farenheit) -> bool;

let temp: Celsius = 32;
is_it_hot(temp);
                        

struct Celsius(i32);
struct Farenheit(i32);
                        

impl Into<Celsius> for Farenheit {
    fn into(c: Celsius) -> Self {
        Self(((c.0 + 9) / 5) as i32 + 32);
    }
}

is_it_hot(temp.into());
                        

Interop with Android, IOS and WASM in the same project

Otávio Pace

FFI

OS How?
iOS C integration
Android JNI
Web WASM

mod common;

#[cfg(target_os = "android")]
mod android;

#[cfg(target_os = "ios")]
mod ios;

#[cfg(target_arch = "wasm32")]
mod wasm;
                        

Rebuilding the Stack for Serverless

Sergio Benitez

Cold Start Preformance

Service Time
AWS Lambda ~1.5s
Google Cloud Functions >2s
Fastly Terrarium (WASM) ~500ms
$2.50 VPS + NGINX ~30ms

Idea

  • Load executable directly into memory
  • Run code

WebAssembly with Rust

Kevin Hoffman

Autor do livro Programming WebAssembly with Rust

Friendly Ferris: Developing Kind Compiler Errors

Esteban Kuber

Procedural Macros vs Sliced Bread

Alex Crichton


#[proc_macro]
pub fn println(input: TokenStream) -> TokenStream
{
   // ???
}
                        

The Power of the "Where" Clause

Florian Gilcher

"Don't start out very generic, refactor towards it!"


fn debug_iter<I>(iter: I) 
where
    I: Iterator,
    I::Item: Debug
{
    // ...
}
                        

trait State { }
trait TerminalState { }
                        

trait TransitionTo<S>
where S: State,
      Self: State
{
    fn transition(self) -> S;
}

trait Terminate
where Self: TerminalState
{
    fn terminate(self);
}
                        

struct Start;
impl State for Start {}

struct Loop;
impl State for Loop {}

struct Stop;
impl State for Stop {}
impl TerminalState for Stop {}
                        

impl TransitionTo<Loop> for Start {
    fn transition(self) -> Loop { ... }
}

impl TransitionTo<Loop> for Loop {
    fn transition(self) -> Loop { ... }
}

impl TransitionTo<End> for Loop {
    fn transition(self) -> End { ... }
}

impl Terminate for End {
    fn terminate(self) { ... }
}
                        

fn main() {
    let initial = Start;
    let next: Loop = initial.transition();
    let next: Loop = next.transition();
    let next: End = next.transition();
    next.terminate();
}
                        

Closing Keynote

Without Boats

Estado geral do async em Rust.