Coming from C, I expected one string type. In Rust, let a = "hello"; gives a &str and let b = String::from("hello"); gives a String, and the compiler rejects passing one where the other is expected with a mismatched types error. So far I have been adding .to_string() and & until it compiles.
What is the actual difference in memory between the two, and is there a rule for which type to use in function parameters, return values and struct fields?




