SlideShare a Scribd company logo
RUST
郭⾄至軒 [:kuoe0]

kuoe0.tw@gmail.com

⾃自由的狐狸
NCKU
2008.09 ~ 2014.12
Programming Contests
Mozilla
2015.01 ~ 2018.01
Firefox Development
NEET
2018.01 ~ Present
Sleep until Noon
What Rust Is
System Programming
Language with Memory
Safety
Common Bugs
In C++
Memory Leak
/* C++ */
while (true) {
int* data = new int[10];
}
Dangling Pointer
Wild Pointer
/* C++ */
int* ptr1 = new int[10];
int* ptr2 = ptr1;
delete ptr2;
ptr1[0] = 0;
ptr2[1] = 1;
/* C++ */
int* ptr;
ptr[0] = 0;
Rust can Avoid Those Issues
in Compilation Time.
Memory Safety
In Rust
Rule 1
Each Value Has Only ONE Owner
Rule 2
Variable Releases OWNING VALUE when Destroying
Rule 3
Not Allow to Use INVALID Variables
let x = vec![1, 2, 3];
variable value
own
Rule 1
Each Value Has Only ONE Owner
Rule 2
Variable Releases OWNING VALUE when Destroying
Rule 3
Not Allow to Use INVALID Variables
not owning or borrowing any value
INVALID
Ownership Control
Lifetime Tracking
Copyable Type
Borrowing & Reference
Ownership Control
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
→ fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
variables
values
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
→ let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
a
vec![1;5]
variables
values
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
→ let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
a b
vec![1;5]
variables
values
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
→ let c = b;
}
let d = vec![2; 5];
foo(d);
}
a b c
vec![1;5]
variables
values
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
→ let d = vec![2; 5];
foo(d);
}
a b c d
variables
values
vec![2;5]
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
→ foo(d);
}
a b c d
variables
values
vec![2;5]
→ fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
a b c d v
variables
values
vec![2;5]
fn foo(v: Vec<i32>) {
→ println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
a b c d v
variables
values
vec![2;5]
fn foo(v: Vec<i32>) {
println!("{:?}", v);
→ }
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
}
a b c d
variables
values
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = a;
{
let c = b;
}
let d = vec![2; 5];
foo(d);
→ }
variables
values
Lifetime Tracking
fn foo(v: Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a: Vec<i32>;
→ println!("{:?}", a);
let b = vec![1; 5];
let c = b;
→ println!("{:?}", b);
}
error[E0381]: use of possibly
uninitialized variable: `a`
--> src/main.rs:7:22
|
7 | println!("{:?}", a);
| ^ use of
| possibly uninitialized `a`
error[E0382]: use of moved value: `b`
--> src/main.rs:11:22
|
10 | let c = b;
| - value moved here
11 | println!("{:?}", b);
| ^ value used
|. here after move
|
Copyable Type
Type implemented Copy trait
do COPY instead of MOVE.
fn foo(v: i32) {
println!("{:?}", v);
}
→ fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
→ let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a
10
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
→ let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b
10 10
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
→ println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b
10 10
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
→ let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b c
10 10 20
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
→ foo(c);
println!("{:?}", c);
}
variables
values
a b c
10 10 20
→ fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b c v
10 10 20 20
fn foo(v: i32) {
→ println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b c v
10 10 20 20
fn foo(v: i32) {
println!("{:?}", v);
→ }
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
}
variables
values
a b c
10 10 20
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
→ println!("{:?}", c);
}
variables
values
a b c
10 10 20
fn foo(v: i32) {
println!("{:?}", v);
}
fn main() {
let a = 10;
let b = a;
println!("{:?}", a);
let c = 20;
foo(c);
println!("{:?}", c);
→ }
variables
values
Borrowing & Reference
let x = vec![1, 2, 3];
let y = &x;
let x = vec![1, 2, 3];
let y = &x;
own
own
let x = vec![1, 2, 3];
let y = &x;
own
own
reference
let x = vec![1, 2, 3];
let y = &x;
own
own
reference
borrow
let x = vec![1, 2, 3];
let y = &x;
borrow
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
→ fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
→ let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a
vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
→ let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b
vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
→ println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b
vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
→ let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b c
vec![2;5]vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
→ foo(&c);
println!("{:?}", c);
}
variables
values
a b c
vec![2;5]vec![1;5]
→ fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b c v
vec![2;5]vec![1;5]
fn foo(v: &Vec<i32>) {
→ println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b c v
vec![2;5]vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
→ }
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
}
variables
values
a b c
vec![2;5]vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
→ println!("{:?}", c);
}
variables
values
a b c
vec![2;5]vec![1;5]
fn foo(v: &Vec<i32>) {
println!("{:?}", v);
}
fn main() {
let a = vec![1; 5];
let b = &a;
println!("{:?}", a);
let c = vec![2; 5];
foo(&c);
println!("{:?}", c);
→ }
variables
values
Cargo
Rust Package Manager
Build System
Dependencies Management
Test Framework
Documentation
Project Initialization
$ cargo new helloworld --bin
Create a new project with Cargo:
Generated files by `cargo new`:
$ tree helloworld
helloworld
!"" Cargo.toml
#"" src
#"" main.rs
Build & Run
$ cargo build
Compiling helloworld v0.1.0 (file:///helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 4.60 secs
Build a project with cargo:
Run the executable program:
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/helloworld`
Hello, world!
Cargo.toml
[package]
# project name
name = "helloworld"
# project version
version = "0.1.0"
# auto info
authors = ["kuoe0 <kuoe0.tw@gmail.com>"]
[dependencies]
rand = "0.4.2" # random number generator
Cargo.toml
[package]
# project name
name = "helloworld"
# project version
version = "0.1.0"
# auto info
authors = ["kuoe0 <kuoe0.tw@gmail.com>"]
[dependencies]
rand = "0.4.2" # random number generator
Package Info
Dependencies List
Dependencies List
[package]
# project name
name = "helloworld"
# project version
version = "0.1.0"
# auto info
authors = ["kuoe0 <kuoe0.tw@gmail.com>"]
[dependencies]
rand = "0.4.2"
libc = "0.2.40"
bitflags = "1.0.3"
serde = "1.0.44"
log = "0.4.1"
$ cargo build
Updating registry `https://github.com/rust-lang/crates.io-
index`
Downloading libc v0.2.40
Downloading cfg-if v0.1.2
Downloading serde v1.0.44
Downloading bitflags v1.0.3
Downloading log v0.4.1
Downloading rand v0.4.2
Compiling libc v0.2.40
Compiling cfg-if v0.1.2
Compiling serde v1.0.44
Compiling bitflags v1.0.3
Compiling log v0.4.1
Compiling rand v0.4.2
Compiling helloworld v0.1.0 (file:///helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 7.97 secs
Install dependencies with `cargo build`
Unit Test
extern crate rand;
fn gen_rand_int_less_100() -> u32 {
rand::random::<u32>() % 100
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_less_100() {
assert!(gen_rand_int_less_100() < 100);
}
}
$ cargo test
Compiling helloworld v0.1.0 (file:///private/tmp/helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 0.48 secs
Running target/debug/deps/helloworld-7a8984a66f00dd7b
running 1 test
test tests::should_less_100 ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0
filtered out
Run unit test with `cargo test`
Documentation
extern crate rand;
/// Return a random number in [0, 100)
///
/// # Example
///
/// ```
/// let r = gen_rand_int_less_100();
/// ```
pub fn gen_rand_int_less_100() -> u32 {
rand::random::<u32>() % 100
}
$ cargo doc
Documenting helloworld v0.1.0 (file:///private/tmp/helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 1.14 secs
Generate the document with `cargo doc`
Rust
Firefox ♥ Rust
Use Rust in Firefox
Servo Browser Engine
A browser engine written in Rust with parallel mechanism
Servo Browser Engine
A browser engine written in Rust with parallel mechanism
Quantum CSS (a.k.a. Stylo)
Use the parallel style engine from Servo in Firefox
Firefox Style Engine Servo Style Engine
replace
Rust
Q & A

More Related Content

What's hot

An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...
Claudio Capobianco
 
Rust system programming language
Rust system programming languageRust system programming language
Rust system programming language
robin_sy
 
Distributed load testing with k6
Distributed load testing with k6Distributed load testing with k6
Distributed load testing with k6
Thijs Feryn
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
Guo Jing
 
All you need to know about the JavaScript event loop
All you need to know about the JavaScript event loopAll you need to know about the JavaScript event loop
All you need to know about the JavaScript event loop
Saša Tatar
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programming
Rodolfo Finochietti
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
Roman Elizarov
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
VMware Tanzu
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
Alexey Soshin
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
Varun Talwar
 
Introduction to Data Oriented Design
Introduction to Data Oriented DesignIntroduction to Data Oriented Design
Introduction to Data Oriented Design
Electronic Arts / DICE
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
L&T Technology Services Limited
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
Brainhub
 
React
React React
React
중운 박
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
Garrett Welson
 
Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is coming
Kirill Rozov
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
Thomas Hunter II
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Codemotion
 

What's hot (20)

An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...An introduction to Rust: the modern programming language to develop safe and ...
An introduction to Rust: the modern programming language to develop safe and ...
 
Rust system programming language
Rust system programming languageRust system programming language
Rust system programming language
 
Distributed load testing with k6
Distributed load testing with k6Distributed load testing with k6
Distributed load testing with k6
 
HTTP2 and gRPC
HTTP2 and gRPCHTTP2 and gRPC
HTTP2 and gRPC
 
All you need to know about the JavaScript event loop
All you need to know about the JavaScript event loopAll you need to know about the JavaScript event loop
All you need to know about the JavaScript event loop
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programming
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
Introduction to Data Oriented Design
Introduction to Data Oriented DesignIntroduction to Data Oriented Design
Introduction to Data Oriented Design
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
React
React React
React
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is coming
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
 

Similar to Rust

Rustlabs Quick Start
Rustlabs Quick StartRustlabs Quick Start
Rustlabs Quick Start
sangam biradar
 
Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
Chih-Hsuan Kuo
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017
pramode_ce
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
GDSCVJTI
 
ES2015 New Features
ES2015 New FeaturesES2015 New Features
ES2015 New Features
Giacomo Zinetti
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
Eduard Tomàs
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
André Faria Gomes
 
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
勇浩 赖
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011
Scalac
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Codemotion
 
Effective C#
Effective C#Effective C#
Effective C#
lantoli
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
Ismar Silveira
 
Go is geting Rusty
Go is geting RustyGo is geting Rusty
Go is geting Rusty
👋 Alon Nativ
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
AvitoTech
 
Groovy for java developers
Groovy for java developersGroovy for java developers
Groovy for java developers
Puneet Behl
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
Anton Arhipov
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
Davide Cerbo
 
C program
C programC program
C program
Komal Singh
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
Emil Vladev
 

Similar to Rust (20)

Rustlabs Quick Start
Rustlabs Quick StartRustlabs Quick Start
Rustlabs Quick Start
 
Ownership System in Rust
Ownership System in RustOwnership System in Rust
Ownership System in Rust
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
 
ES2015 New Features
ES2015 New FeaturesES2015 New Features
ES2015 New Features
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?为什么 rust-lang 吸引我?
为什么 rust-lang 吸引我?
 
Scala 3camp 2011
Scala   3camp 2011Scala   3camp 2011
Scala 3camp 2011
 
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017 Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
 
Effective C#
Effective C#Effective C#
Effective C#
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Go is geting Rusty
Go is geting RustyGo is geting Rusty
Go is geting Rusty
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
 
Groovy for java developers
Groovy for java developersGroovy for java developers
Groovy for java developers
 
Something about Golang
Something about GolangSomething about Golang
Something about Golang
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
C program
C programC program
C program
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 

More from Chih-Hsuan Kuo

[Mozilla] content-select
[Mozilla] content-select[Mozilla] content-select
[Mozilla] content-select
Chih-Hsuan Kuo
 
在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。
Chih-Hsuan Kuo
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
Chih-Hsuan Kuo
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
Chih-Hsuan Kuo
 
Pocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OSPocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OS
Chih-Hsuan Kuo
 
Necko walkthrough
Necko walkthroughNecko walkthrough
Necko walkthrough
Chih-Hsuan Kuo
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
Chih-Hsuan Kuo
 
面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!
Chih-Hsuan Kuo
 
面試心得分享
面試心得分享面試心得分享
面試心得分享
Chih-Hsuan Kuo
 
Windows 真的不好用...
Windows 真的不好用...Windows 真的不好用...
Windows 真的不好用...
Chih-Hsuan Kuo
 
Python @Wheel Lab
Python @Wheel LabPython @Wheel Lab
Python @Wheel Lab
Chih-Hsuan Kuo
 
Introduction to VP8
Introduction to VP8Introduction to VP8
Introduction to VP8
Chih-Hsuan Kuo
 
Python @NCKU CSIE
Python @NCKU CSIEPython @NCKU CSIE
Python @NCKU CSIE
Chih-Hsuan Kuo
 
[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism
Chih-Hsuan Kuo
 
[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm
Chih-Hsuan Kuo
 
[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set
Chih-Hsuan Kuo
 
[ACM-ICPC] Traversal
[ACM-ICPC] Traversal[ACM-ICPC] Traversal
[ACM-ICPC] Traversal
Chih-Hsuan Kuo
 
[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245
Chih-Hsuan Kuo
 
[ACM-ICPC] Sort
[ACM-ICPC] Sort[ACM-ICPC] Sort
[ACM-ICPC] Sort
Chih-Hsuan Kuo
 

More from Chih-Hsuan Kuo (20)

[Mozilla] content-select
[Mozilla] content-select[Mozilla] content-select
[Mozilla] content-select
 
在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。在開始工作以前,我以為我會寫扣。
在開始工作以前,我以為我會寫扣。
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
Pocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OSPocket Authentication with OAuth on Firefox OS
Pocket Authentication with OAuth on Firefox OS
 
Necko walkthrough
Necko walkthroughNecko walkthrough
Necko walkthrough
 
Protocol handler in Gecko
Protocol handler in GeckoProtocol handler in Gecko
Protocol handler in Gecko
 
面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!面試面試面試,因為很重要所以要說三次!
面試面試面試,因為很重要所以要說三次!
 
應徵軟體工程師
應徵軟體工程師應徵軟體工程師
應徵軟體工程師
 
面試心得分享
面試心得分享面試心得分享
面試心得分享
 
Windows 真的不好用...
Windows 真的不好用...Windows 真的不好用...
Windows 真的不好用...
 
Python @Wheel Lab
Python @Wheel LabPython @Wheel Lab
Python @Wheel Lab
 
Introduction to VP8
Introduction to VP8Introduction to VP8
Introduction to VP8
 
Python @NCKU CSIE
Python @NCKU CSIEPython @NCKU CSIE
Python @NCKU CSIE
 
[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism[ACM-ICPC] Tree Isomorphism
[ACM-ICPC] Tree Isomorphism
 
[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm[ACM-ICPC] Dinic's Algorithm
[ACM-ICPC] Dinic's Algorithm
 
[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set[ACM-ICPC] Disjoint Set
[ACM-ICPC] Disjoint Set
 
[ACM-ICPC] Traversal
[ACM-ICPC] Traversal[ACM-ICPC] Traversal
[ACM-ICPC] Traversal
 
[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245[ACM-ICPC] UVa-10245
[ACM-ICPC] UVa-10245
 
[ACM-ICPC] Sort
[ACM-ICPC] Sort[ACM-ICPC] Sort
[ACM-ICPC] Sort
 

Recently uploaded

dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
@Call @Girls in Kolkata 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Kolkata Avaulable
 @Call @Girls in Kolkata 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Kolkata Avaulable @Call @Girls in Kolkata 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Kolkata Avaulable
@Call @Girls in Kolkata 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Kolkata Avaulable
DiyaSharma6551
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
DNUG e.V.
 
@Call @Girls in Aligarh 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
 @Call @Girls in Aligarh 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A... @Call @Girls in Aligarh 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
@Call @Girls in Aligarh 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
msriya3
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
shristi verma
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
ThousandEyes
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
williamrobertherman
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
bangalore @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
bangalore @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meetbangalore @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
bangalore @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
rajesvigrag
 
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai AvailableDombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
cristine510
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
arvindkumarji156
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
Mona Rathore
 

Recently uploaded (20)

dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
 
Folding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a seriesFolding Cheat Sheet #7 - seventh in a series
Folding Cheat Sheet #7 - seventh in a series
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
@Call @Girls in Kolkata 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Kolkata Avaulable
 @Call @Girls in Kolkata 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Kolkata Avaulable @Call @Girls in Kolkata 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Kolkata Avaulable
@Call @Girls in Kolkata 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Kolkata Avaulable
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
 
@Call @Girls in Aligarh 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
 @Call @Girls in Aligarh 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A... @Call @Girls in Aligarh 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
@Call @Girls in Aligarh 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Tanisha Sharma Best High Class A...
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
bangalore @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
bangalore @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meetbangalore @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
bangalore @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 WhatsApp Number for Real Meet
 
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai AvailableDombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
 
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ... @Call @Girls in Tiruppur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
@Call @Girls in Tiruppur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class ...
 

Rust

  • 2. NCKU 2008.09 ~ 2014.12 Programming Contests Mozilla 2015.01 ~ 2018.01 Firefox Development NEET 2018.01 ~ Present Sleep until Noon
  • 6. Memory Leak /* C++ */ while (true) { int* data = new int[10]; } Dangling Pointer Wild Pointer /* C++ */ int* ptr1 = new int[10]; int* ptr2 = ptr1; delete ptr2; ptr1[0] = 0; ptr2[1] = 1; /* C++ */ int* ptr; ptr[0] = 0;
  • 7. Rust can Avoid Those Issues in Compilation Time.
  • 9. Rule 1 Each Value Has Only ONE Owner Rule 2 Variable Releases OWNING VALUE when Destroying Rule 3 Not Allow to Use INVALID Variables
  • 10. let x = vec![1, 2, 3]; variable value own
  • 11. Rule 1 Each Value Has Only ONE Owner Rule 2 Variable Releases OWNING VALUE when Destroying Rule 3 Not Allow to Use INVALID Variables not owning or borrowing any value INVALID
  • 12. Ownership Control Lifetime Tracking Copyable Type Borrowing & Reference
  • 14. fn foo(v: Vec<i32>) { println!("{:?}", v); } → fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } variables values
  • 15. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { → let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } a vec![1;5] variables values
  • 16. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; → let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } a b vec![1;5] variables values
  • 17. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { → let c = b; } let d = vec![2; 5]; foo(d); } a b c vec![1;5] variables values
  • 18. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } → let d = vec![2; 5]; foo(d); } a b c d variables values vec![2;5]
  • 19. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; → foo(d); } a b c d variables values vec![2;5]
  • 20. → fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } a b c d v variables values vec![2;5]
  • 21. fn foo(v: Vec<i32>) { → println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } a b c d v variables values vec![2;5]
  • 22. fn foo(v: Vec<i32>) { println!("{:?}", v); → } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); } a b c d variables values
  • 23. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = a; { let c = b; } let d = vec![2; 5]; foo(d); → } variables values
  • 25. fn foo(v: Vec<i32>) { println!("{:?}", v); } fn main() { let a: Vec<i32>; → println!("{:?}", a); let b = vec![1; 5]; let c = b; → println!("{:?}", b); } error[E0381]: use of possibly uninitialized variable: `a` --> src/main.rs:7:22 | 7 | println!("{:?}", a); | ^ use of | possibly uninitialized `a` error[E0382]: use of moved value: `b` --> src/main.rs:11:22 | 10 | let c = b; | - value moved here 11 | println!("{:?}", b); | ^ value used |. here after move |
  • 27. Type implemented Copy trait do COPY instead of MOVE.
  • 28. fn foo(v: i32) { println!("{:?}", v); } → fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values
  • 29. fn foo(v: i32) { println!("{:?}", v); } fn main() { → let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a 10
  • 30. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; → let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a b 10 10
  • 31. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; → println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a b 10 10
  • 32. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); → let c = 20; foo(c); println!("{:?}", c); } variables values a b c 10 10 20
  • 33. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; → foo(c); println!("{:?}", c); } variables values a b c 10 10 20
  • 34. → fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a b c v 10 10 20 20
  • 35. fn foo(v: i32) { → println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a b c v 10 10 20 20
  • 36. fn foo(v: i32) { println!("{:?}", v); → } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); } variables values a b c 10 10 20
  • 37. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); → println!("{:?}", c); } variables values a b c 10 10 20
  • 38. fn foo(v: i32) { println!("{:?}", v); } fn main() { let a = 10; let b = a; println!("{:?}", a); let c = 20; foo(c); println!("{:?}", c); → } variables values
  • 40. let x = vec![1, 2, 3]; let y = &x;
  • 41. let x = vec![1, 2, 3]; let y = &x; own own
  • 42. let x = vec![1, 2, 3]; let y = &x; own own reference
  • 43. let x = vec![1, 2, 3]; let y = &x; own own reference borrow
  • 44. let x = vec![1, 2, 3]; let y = &x; borrow
  • 45. fn foo(v: &Vec<i32>) { println!("{:?}", v); } → fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values
  • 46. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { → let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a vec![1;5]
  • 47. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; → let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b vec![1;5]
  • 48. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; → println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b vec![1;5]
  • 49. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); → let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b c vec![2;5]vec![1;5]
  • 50. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; → foo(&c); println!("{:?}", c); } variables values a b c vec![2;5]vec![1;5]
  • 51. → fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b c v vec![2;5]vec![1;5]
  • 52. fn foo(v: &Vec<i32>) { → println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b c v vec![2;5]vec![1;5]
  • 53. fn foo(v: &Vec<i32>) { println!("{:?}", v); → } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); } variables values a b c vec![2;5]vec![1;5]
  • 54. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); → println!("{:?}", c); } variables values a b c vec![2;5]vec![1;5]
  • 55. fn foo(v: &Vec<i32>) { println!("{:?}", v); } fn main() { let a = vec![1; 5]; let b = &a; println!("{:?}", a); let c = vec![2; 5]; foo(&c); println!("{:?}", c); → } variables values
  • 57. Build System Dependencies Management Test Framework Documentation
  • 58. Project Initialization $ cargo new helloworld --bin Create a new project with Cargo: Generated files by `cargo new`: $ tree helloworld helloworld !"" Cargo.toml #"" src #"" main.rs
  • 59. Build & Run $ cargo build Compiling helloworld v0.1.0 (file:///helloworld) Finished dev [unoptimized + debuginfo] target(s) in 4.60 secs Build a project with cargo: Run the executable program: $ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs Running `target/debug/helloworld` Hello, world!
  • 60. Cargo.toml [package] # project name name = "helloworld" # project version version = "0.1.0" # auto info authors = ["kuoe0 <kuoe0.tw@gmail.com>"] [dependencies] rand = "0.4.2" # random number generator
  • 61. Cargo.toml [package] # project name name = "helloworld" # project version version = "0.1.0" # auto info authors = ["kuoe0 <kuoe0.tw@gmail.com>"] [dependencies] rand = "0.4.2" # random number generator Package Info Dependencies List
  • 62. Dependencies List [package] # project name name = "helloworld" # project version version = "0.1.0" # auto info authors = ["kuoe0 <kuoe0.tw@gmail.com>"] [dependencies] rand = "0.4.2" libc = "0.2.40" bitflags = "1.0.3" serde = "1.0.44" log = "0.4.1"
  • 63. $ cargo build Updating registry `https://github.com/rust-lang/crates.io- index` Downloading libc v0.2.40 Downloading cfg-if v0.1.2 Downloading serde v1.0.44 Downloading bitflags v1.0.3 Downloading log v0.4.1 Downloading rand v0.4.2 Compiling libc v0.2.40 Compiling cfg-if v0.1.2 Compiling serde v1.0.44 Compiling bitflags v1.0.3 Compiling log v0.4.1 Compiling rand v0.4.2 Compiling helloworld v0.1.0 (file:///helloworld) Finished dev [unoptimized + debuginfo] target(s) in 7.97 secs Install dependencies with `cargo build`
  • 64. Unit Test extern crate rand; fn gen_rand_int_less_100() -> u32 { rand::random::<u32>() % 100 } #[cfg(test)] mod tests { use super::*; #[test] fn should_less_100() { assert!(gen_rand_int_less_100() < 100); } }
  • 65. $ cargo test Compiling helloworld v0.1.0 (file:///private/tmp/helloworld) Finished dev [unoptimized + debuginfo] target(s) in 0.48 secs Running target/debug/deps/helloworld-7a8984a66f00dd7b running 1 test test tests::should_less_100 ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Run unit test with `cargo test`
  • 66. Documentation extern crate rand; /// Return a random number in [0, 100) /// /// # Example /// /// ``` /// let r = gen_rand_int_less_100(); /// ``` pub fn gen_rand_int_less_100() -> u32 { rand::random::<u32>() % 100 }
  • 67. $ cargo doc Documenting helloworld v0.1.0 (file:///private/tmp/helloworld) Finished dev [unoptimized + debuginfo] target(s) in 1.14 secs Generate the document with `cargo doc`
  • 69. Firefox ♥ Rust Use Rust in Firefox
  • 70. Servo Browser Engine A browser engine written in Rust with parallel mechanism
  • 71. Servo Browser Engine A browser engine written in Rust with parallel mechanism Quantum CSS (a.k.a. Stylo) Use the parallel style engine from Servo in Firefox
  • 72. Firefox Style Engine Servo Style Engine replace
  • 74. Q & A