Hey, there's a local Rust meetup
in the Triangle area!
Check them out!
meetup.com/triangle-rustaceans/
Get these slides at slides.com/bstrie/ato-2017
# Python ranges
for i in range(0, n):
# Do something n times
// Rust ranges
for i in 0..n {
// Do something n times
}
// Javascript closures
let x = 2;
let y = (z) => z + x;
y(3); // 5
// Rust closures
let x = 2;
let y = |z| x + z;
y(3);
# Ruby iterators
(0...x).inject(0) {|sum, i| sum + i}
// Rust iterators
(0..x).fold(0, |sum, i| sum + i)
; Assembly for above example
lea eax, [rdi - 1]
lea ecx, [rdi - 2]
imul rcx, rax
shr rcx
lea eax, [rcx + rdi - 1]
// Rust iterators
(0..n).fold(0, |sum, i| sum + i)
decltype(auto) foo() {
int x = 1;
return x;
}
decltype(auto) bar() {
int x = 1;
return (x);
}
Well, let's see how much time we have left...
Get these slides at slides.com/bstrie/ato-2017