Why if I write (case 1)
let i = String::from("sample");
println! ("{}", i);
println! ("{}", i);
compiles fine but,(case 2)
let i = String::from("sample");
some_function(i);
println! ("{}", i);
It gives the borrow error. The second part I understood it. It is violating the borrow rules in the second part. But, in case 1, The first println!
the variable i is borrowed. seems like error should be thrown but, I think my guess println!
is not like an actual function. Can anyone explain what's going on here?