Reduce usage of as_ref and as_mut.

This commit is contained in:
Stephen Chung
2022-07-05 16:26:38 +08:00
parent 9319f87a7b
commit b6528bd51d
33 changed files with 211 additions and 137 deletions

View File

@@ -3,7 +3,11 @@ use crate::{
};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{collections::btree_map::IntoIter, collections::BTreeMap, ops::AddAssign};
use std::{
collections::btree_map::{IntoIter, Iter},
collections::BTreeMap,
ops::AddAssign,
};
/// A static [module][Module] resolution service that serves [modules][Module] added into it.
///
@@ -122,11 +126,22 @@ impl IntoIterator for StaticModuleResolver {
type Item = (Identifier, Shared<Module>);
type IntoIter = IntoIter<SmartString, Shared<Module>>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
impl<'a> IntoIterator for &'a StaticModuleResolver {
type Item = (&'a Identifier, &'a Shared<Module>);
type IntoIter = Iter<'a, SmartString, Shared<Module>>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}
impl ModuleResolver for StaticModuleResolver {
#[inline]
fn resolve(