A short intro
With Pokémons, of course.
C/C++
Ruby/JS
Haskell/FP
C/C++
Ruby/JS
Haskell/FP
C/C++ - don't want GC
Ruby/JS -Nice language with compiler support
Haskell/FP - interesting type system
Starter
Starter
Cargo
Compiles, links and organises project dependencies in a single place
cargo new pokemon --bin
Source: http://doc.crates.io/guide.html
Starter
"hello world"
fn main() {
let party_size = 6;
}
fn main() {
let party_size = 6;
party_size = 5;
}
src/main.rs:3:5: 3:19 error: re-assignment of immutable variable `party_size` [E0384]
rustc --explain E0384
fn main() {
let party_size = 6;
}
fn main() {
let mut party_size = 6;
party_size = 5;
}
It's super effective :)
let party_size: i32 = 6;
let party_size: i32;
Level up!
fn level_up(level: i32) {
println!("Level up {}", level + 1);
}
fn level_up(level) {
println!("Level up {}", level + 1);
}
fn level_up_with_rare_candy(level: i32) -> i32 {
level + 1
}
fn level_up_with_rare_candy(level: i32) -> i32 {
level + 1;
}
Starter
"hello world"
Expressions vs statements
fn use_potion(hp: i32) -> i32 {
hp + 20
}
let current_hp = use_potion;
Function Pointers
let healed_hp = current_hp(5);
Rust Primitive Types
ifs and loops
(Sp Def ==Safety)
let pokemons = vec![1, 2, 3, 4, 5, 6];
fn foo() {
}
But not in a battle!
You cannot capture your rival's Pokémon. You can throw the Pokéball, however.
let pokemons = vec![1, 2, 3, 4, 5, 6];
let pokemons_rival = pokemons;
println!("Capturei {}", pokemons[0]);
Wrong! One Pokémon, two trainers! That's wrong.
You can clone the Pokémon ( ͡° ͜ʖ ͡°)
Or **borrow** it
let pokemons = vec![1, 2, 3];
let pokemons_extras = vec![4, 5, 6];
let pokemon_party = forma_party(&v1, &v2);
let mut attack = 5;
{
let new_attack = &mut attack;
*new_attack += 1;
}
println!("{}", attack);
Starter
"hello world"
@Argorak
Questions?
hannelita@gmail.com
@hannelita