Avoid hard-coding variable type for shared.

This commit is contained in:
Stephen Chung
2020-08-01 22:28:13 +08:00
parent af2f8acb5d
commit cc53b21731
4 changed files with 71 additions and 86 deletions

View File

@@ -264,6 +264,18 @@ impl AddAssign<&ImmutableString> for ImmutableString {
}
}
impl AddAssign<ImmutableString> for ImmutableString {
fn add_assign(&mut self, rhs: ImmutableString) {
if !rhs.is_empty() {
if self.is_empty() {
self.0 = rhs.0;
} else {
self.make_mut().push_str(rhs.0.as_str());
}
}
}
}
impl Add<&str> for ImmutableString {
type Output = Self;