Implement Add for String + String

Regardless of how it’s spelled (+ or ~ or method call or …), I have some reservations about concatenating String with String. In programs of this form:

// concatenate s1 and s2
// keep using s2

… it is preferable to use String + &str and simply reuse s2, rather than creating an explicit clone of s2 before concatenating. An overload for String + String makes it easier to unthinkingly do the pointless clone. Now, if one ever needed to do String + String (e.g. for performance reasons), this downside would not be a blocker, but since it’s apparently just an ergonomics issues, it is a trade off.

3 Likes