Add convenient functions and operators for Module and module resolvers.
This commit is contained in:
@@ -33,7 +33,7 @@ use crate::stdlib::{
|
||||
fmt, format,
|
||||
iter::empty,
|
||||
num::NonZeroUsize,
|
||||
ops::{Deref, DerefMut},
|
||||
ops::{Add, AddAssign, Deref, DerefMut},
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
@@ -1546,6 +1546,38 @@ impl From<StaticVec<(String, Position)>> for ModuleRef {
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<Module> for Module {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: Module) -> Self::Output {
|
||||
let mut module = self.clone();
|
||||
module.merge(&rhs);
|
||||
module
|
||||
}
|
||||
}
|
||||
|
||||
impl Add<&Module> for Module {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, rhs: &Module) -> Self::Output {
|
||||
let mut module = self.clone();
|
||||
module.merge(rhs);
|
||||
module
|
||||
}
|
||||
}
|
||||
|
||||
impl AddAssign<Module> 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 ModuleRef {
|
||||
pub(crate) fn index(&self) -> Option<NonZeroUsize> {
|
||||
self.1
|
||||
|
Reference in New Issue
Block a user