Refine Add/AddAssign for AST and Module.
This commit is contained in:
parent
d35c216465
commit
b2d603ec06
@ -1546,35 +1546,28 @@ impl From<StaticVec<(String, Position)>> for ModuleRef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Module> for Module {
|
impl<M: AsRef<Module>> Add<M> for &Module {
|
||||||
type Output = Self;
|
type Output = Module;
|
||||||
|
|
||||||
fn add(self, rhs: Module) -> Self::Output {
|
fn add(self, rhs: M) -> Self::Output {
|
||||||
let mut module = self.clone();
|
let mut module = self.clone();
|
||||||
module.merge(&rhs);
|
module.merge(rhs.as_ref());
|
||||||
module
|
module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<&Module> for Module {
|
impl<M: AsRef<Module>> Add<M> for Module {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, rhs: &Module) -> Self::Output {
|
fn add(mut self, rhs: M) -> Self::Output {
|
||||||
let mut module = self.clone();
|
self.merge(rhs.as_ref());
|
||||||
module.merge(rhs);
|
self
|
||||||
module
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<Module> for Module {
|
impl<M: Into<Module>> AddAssign<M> for Module {
|
||||||
fn add_assign(&mut self, rhs: Module) {
|
fn add_assign(&mut self, rhs: M) {
|
||||||
self.combine(rhs);
|
self.combine(rhs.into());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddAssign<&Module> for Module {
|
|
||||||
fn add_assign(&mut self, rhs: &Module) {
|
|
||||||
self.merge(rhs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,25 +443,17 @@ impl AST {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<Self> for &AST {
|
impl<A: AsRef<AST>> Add<A> for &AST {
|
||||||
type Output = AST;
|
type Output = AST;
|
||||||
|
|
||||||
fn add(self, rhs: Self) -> Self::Output {
|
fn add(self, rhs: A) -> Self::Output {
|
||||||
self.merge(rhs)
|
self.merge(rhs.as_ref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<&Self> for &AST {
|
impl<A: Into<AST>> AddAssign<A> for AST {
|
||||||
type Output = AST;
|
fn add_assign(&mut self, rhs: A) {
|
||||||
|
self.combine(rhs.into());
|
||||||
fn add(self, rhs: &Self) -> Self::Output {
|
|
||||||
self.merge(rhs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddAssign<AST> for AST {
|
|
||||||
fn add_assign(&mut self, rhs: AST) {
|
|
||||||
self.combine(rhs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user