Borrowing
fn main() { let s1 = String::from("hello"); let s = &s1; let len = calculate_lenght(s); println!("len is {}", len); } fn calculate_lenght(s: &String) -> usize { s.len() }
fn main() { let s1 = String::from("hello"); let s = &s1; let len = calculate_lenght(s); println!("len is {}", len); } fn calculate_lenght(s: &String) -> usize { s.len() }