& the dream of static safety
Compiler Knowledge
pure fn not_empty(a: [int]) -> bool { ... } fn last(a: [int]) : not_empty(a) -> int { ... } let my_array = [1]; check not_empty(my_array); log(last(my_array));
type point = {x: float, y: float} fn angle(vec: point) -> float { ... } log(angle({x: 4.0, y: 2.0}));
type collection<T> = obj { fn length() -> int ; fn item(int) -> T } fn is_big(c: @obj { fn length() -> int }) -> bool { ... } log(is_big(my_collection));
Segmented stacks
Returning a closure
fn factory() -> Box<Fn(i32) -> i32> { let num = 5; Box::new(move |x| x + num) }