A JavaScript developer learning Rust #2

preview_player
Показать описание
I will be reading chapters in the book "The Rust Programming Language" and share what I have learned with you the day after. This is RAW learning and nothing is prepared, but hopefully it will be a good format that fights impostor syndrom and inspires you to maybe learn the language as well!
Рекомендации по теме
Комментарии
Автор

there are closures in rust:
let b = 2;
let f = |a: i32| a + b; // this is a closure, a is a parameter (the parameter list is contained in those '|' symbols) and it captures b.
let c = f(5);
println!("a + b = {}", c); // c is 7
However there are a more advanced feature and i advice getting more familiar with owership and borrowing first.

benmuker
Автор

In javascript primitive such as Number, String, Boolean, etc go on the stack. Objects are "reference types" which means they go on the heap.

echobucket