Passing by reference

A variable passed by a reference looks like this:

fn my_function(a: &i32, b: &i32) -> i32 

We take two variables as references, and return a value.

To obtain a value from a reference, the first thing to do is dereference it. This is done with the asterisk (*) operator:

let ref_num = &2; 
let deref_num = *ref_num; 
// deref_num = 2 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset