I’m digging into Rust for the first time, with a primarily ObjC and Javascript (sigh) background, and working with a few of the playgrounds.
I’m trying to understand the -> (aka "thin arrow??") symbol in Rust and how I am supposed to interpret this when reading Rust statements
>Solution :
In rust -> meaning the return of the function. In rust function exactly need to specify the return type so when you declare a function that return that adds one to the integer you have to specify the return type i32 of the function
fn add_one(x:i32) -> i32
{
x+1
}
you have to declare x+1 to add one and return the value. note that when you return the value you do not declare semicolon after x+1; like that. declaring semicolon means its an expression and not return. in rust returning values they do not end with semicolon.