« first day (2850 days earlier)      last day (653 days later) » 

7:47 PM
Hello,

I am a beginner in rust, reading rust-lang.org book. I have a basic question.

While explaining references, it said that a reference is like a pointer. I know C, so I can relate that.

But then, in the below program, how is len() working with both s1 in main and s in the calculate_..

```
fn main() {
let s1 = String::from("hello");

let len = calculate_length(&s1);

println!("The length of '{}' is {} = {}", s1, s1.len(), len);
}

fn calculate_length(s: &String) -> usize {
s.len()
}

```
Weird. I expected markdown to work..
 
 
1 hour later…
9:17 PM
break it down further:

let s1 = String::from("hello");
let s = &s1;
let len = s.len();
println!("The length of '{}' is {} = {}", s1, s1.len(), len);

Does this still puzzle you? What do you think should happen here?
 

« first day (2850 days earlier)      last day (653 days later) »