I was reading rust book when I came across this:
fn main() {
let s1 = String::from("Hello, ");
let s2 = String::from("world!");
let s3 = s1 + &s2; // note s1 has been moved here and can no longer be used
}
as it turns out 'The + operator uses the add method, whose signature looks something like this':
fn add(self, s: &str) -> String { // ... }
I understand the reason why s1 is 'consumed' and is no longer available later. But why does rust do this? I mean, why can't add method have reference to self (&self) as a first parameter, so that s1 string will be available for later use?