Julio Biason
6 years ago
3 changed files with 369 additions and 0 deletions
After Width: | Height: | Size: 4.5 KiB |
@ -0,0 +1,365 @@
|
||||
<!doctype html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
|
||||
<title>Rust</title> |
||||
|
||||
<meta name="description" content="O que Rust tem de legal"> |
||||
<meta name="author" content="Julio Biason"> |
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"> |
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> |
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> |
||||
|
||||
<link rel="stylesheet" href="reveal.js/css/reveal.css"> |
||||
<link rel="stylesheet" href="reveal.js/css/theme/night.css" id="theme"> |
||||
|
||||
<!-- Code syntax highlighting --> |
||||
<link rel="stylesheet" href="reveal.js/lib/css/zenburn.css"> |
||||
|
||||
<!-- Printing and PDF exports --> |
||||
<script> |
||||
var link = document.createElement( 'link' ); |
||||
link.rel = 'stylesheet'; |
||||
link.type = 'text/css'; |
||||
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css'; |
||||
document.getElementsByTagName( 'head' )[0].appendChild( link ); |
||||
</script> |
||||
|
||||
<!--[if lt IE 9]> |
||||
<script src="lib/js/html5shiv.js"></script> |
||||
<![endif]--> |
||||
|
||||
<style type="text/css" media="screen"> |
||||
.happy { |
||||
color: yellow; |
||||
} |
||||
|
||||
.reveal section img { |
||||
border: none; |
||||
} |
||||
|
||||
.reveal ul.empty { |
||||
list-style: none outside; |
||||
} |
||||
|
||||
li { |
||||
display: block; |
||||
} |
||||
|
||||
.cursor { |
||||
background-color: #666; |
||||
color: white; |
||||
} |
||||
|
||||
img { |
||||
max-height: 90%; |
||||
} |
||||
|
||||
td.seen { |
||||
font-style: italic; |
||||
font-weight: bold; |
||||
} |
||||
|
||||
.semi-opaque { |
||||
background-color: rgba(0, 0, 0, 0.7); |
||||
} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<div class="reveal"> |
||||
<div class="slides"> |
||||
<section> |
||||
<section data-background="_images/rust.png" data-header> |
||||
<h1 class="semi-opaque">O Que Rust Tem de Legal</h1> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Borrow Checker</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
a = 2 |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
"Variável <code>a</code> tem o valor 2" |
||||
</section> |
||||
|
||||
<section> |
||||
<div> |
||||
"Posição de memória apontada por <code>a</code> tem o valor 2" |
||||
</div> |
||||
|
||||
<div class="fragment"> |
||||
<pre><code> |
||||
0x3f5cbf89 = 2 |
||||
</code></pre> |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<div> |
||||
A language that doesn't affect the way you think |
||||
about programming, is not worth knowing. |
||||
</div> |
||||
|
||||
<div> |
||||
-- Alan Perlis, "ALGOL" |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
fn main() { |
||||
let a = String::from("hello"); |
||||
let _b = a; |
||||
println!("{}", a) |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
error[E0382]: borrow of moved value: `a` |
||||
--> src/main.rs:5:20 |
||||
| |
||||
4 | let _b = a; |
||||
| - value moved here |
||||
5 | println!("{}", a) |
||||
| ^ value borrowed here after move |
||||
| |
||||
= note: move occurs because `a` has type `std::string::String`, which does not implement the `Copy` trait |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
fn main() { |
||||
let a = 2; |
||||
let b = a; |
||||
println!("{}", a); |
||||
println!("{}", b); |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
2 |
||||
2 |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<a href="https://swift.org/blog/swift-5-exclusivity/">Swift 5 Exclusivity Enforcement</a> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Imutabilidade por Default</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
fn main() { |
||||
let a = 2; |
||||
a = 3; |
||||
println!("{}", a); |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
3 | let a = 2; |
||||
| - |
||||
| | |
||||
| first assignment to `a` |
||||
| help: make this binding mutable: `mut a` |
||||
4 | a = 3; |
||||
| ^^^^^ cannot assign twice to immutable variable |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
fn main() { |
||||
let mut a = 2; |
||||
a = 3; |
||||
println!("{}", a); |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Enums</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
enum IpAddr { |
||||
V4, |
||||
V6 |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
enum IpAddr { |
||||
V4(String), |
||||
V6(String), |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
let home = IpAddr::V4(String::from("127.0.0.1"); |
||||
|
||||
match home { |
||||
V4(address) => println!("IPv4 addr: {}", address), |
||||
V6(address) => println!("Ipv6 addr: {}", address), |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
enum Option<T> { |
||||
Some(T), |
||||
None |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
</section> |
||||
|
||||
<section> |
||||
<section> |
||||
<h2>Error Control</h2> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
try: |
||||
something() |
||||
except Exception: |
||||
pass |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
try { |
||||
something(); |
||||
} catch (Exception ex) { |
||||
System.out.println(ex); |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
FILE* f = fopen("someting.txt", "wb"); |
||||
fprintf(f, "Done!"); |
||||
fclose(f); |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<div> |
||||
Onde o erro foi tratado nisso? |
||||
</div> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
enum Result<T, E> { |
||||
Ok(T), |
||||
Err(E), |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
File::create("something.txt") match { |
||||
Ok(fp) => fp.write_all(b"Hello world"), |
||||
Err(err) => println!("Failure! {}", err), |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
File::create("something.txt") match { |
||||
Ok(fp) => fp.write_all(b"Hello world") match { |
||||
Ok(_) => (), |
||||
Err(err) => println!("Can't write! {}", err), |
||||
} |
||||
Err(err) => println!("Failure! {}", err), |
||||
} |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
let mut file = File::create("something.txt).unwrap(); |
||||
file.write(b"Hello world").unwrap(); |
||||
</code></pre> |
||||
</section> |
||||
|
||||
<section> |
||||
<pre><code> |
||||
let mut file = File::create("something.txt)?; |
||||
file.write(b"Hello world")?; |
||||
OK(()) |
||||
</code></pre> |
||||
</section> |
||||
</section> |
||||
|
||||
<section data-background='_images/thats-all-folks.jpg'> |
||||
</section> |
||||
</div> |
||||
</div> |
||||
|
||||
<script src="reveal.js/lib/js/head.min.js"></script> |
||||
<script src="reveal.js/js/reveal.js"></script> |
||||
|
||||
<script> |
||||
// Full list of configuration options available at: |
||||
// https://github.com/hakimel/reveal.js#configuration |
||||
Reveal.initialize({ |
||||
controls: true, |
||||
progress: true, |
||||
history: true, |
||||
center: true, |
||||
// showNotes: true, |
||||
|
||||
transition: 'slide', // none/fade/slide/convex/concave/zoom |
||||
|
||||
// Optional reveal.js plugins |
||||
dependencies: [ |
||||
{ src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } }, |
||||
{ src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, |
||||
{ src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, |
||||
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true }, |
||||
{ src: 'reveal.js/plugin/notes/notes.js', async: true } |
||||
] |
||||
}); |
||||
</script> |
||||
|
||||
</body> |
||||
</html> |
Loading…
Reference in new issue