diff --git a/src/module/mod.rs b/src/module/mod.rs index 305cdbc9..c05be2be 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1546,35 +1546,28 @@ impl From> for ModuleRef { } } -impl Add for Module { - type Output = Self; +impl> Add for &Module { + type Output = Module; - fn add(self, rhs: Module) -> Self::Output { + fn add(self, rhs: M) -> Self::Output { let mut module = self.clone(); - module.merge(&rhs); + module.merge(rhs.as_ref()); module } } -impl Add<&Module> for Module { +impl> Add for Module { type Output = Self; - fn add(self, rhs: &Module) -> Self::Output { - let mut module = self.clone(); - module.merge(rhs); - module + fn add(mut self, rhs: M) -> Self::Output { + self.merge(rhs.as_ref()); + self } } -impl AddAssign for Module { - fn add_assign(&mut self, rhs: Module) { - self.combine(rhs); - } -} - -impl AddAssign<&Module> for Module { - fn add_assign(&mut self, rhs: &Module) { - self.merge(rhs); +impl> AddAssign for Module { + fn add_assign(&mut self, rhs: M) { + self.combine(rhs.into()); } } diff --git a/src/parser.rs b/src/parser.rs index c83daba9..aa6effdb 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -443,25 +443,17 @@ impl AST { } } -impl Add for &AST { +impl> Add for &AST { type Output = AST; - fn add(self, rhs: Self) -> Self::Output { - self.merge(rhs) + fn add(self, rhs: A) -> Self::Output { + self.merge(rhs.as_ref()) } } -impl Add<&Self> for &AST { - type Output = AST; - - fn add(self, rhs: &Self) -> Self::Output { - self.merge(rhs) - } -} - -impl AddAssign for AST { - fn add_assign(&mut self, rhs: AST) { - self.combine(rhs); +impl> AddAssign for AST { + fn add_assign(&mut self, rhs: A) { + self.combine(rhs.into()); } }