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

@@ -1,7 +1,7 @@
use crate::{Engine, Module, ModuleResolver, Position, RhaiResultOf, Shared, ERR};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{ops::AddAssign, vec::IntoIter};
use std::{ops::AddAssign, slice::Iter, vec::IntoIter};
/// [Module] resolution service that holds a collection of module resolvers,
/// to be searched in sequential order.
@@ -116,6 +116,16 @@ impl IntoIterator for ModuleResolversCollection {
}
}
impl<'a> IntoIterator for &'a ModuleResolversCollection {
type Item = &'a Box<dyn ModuleResolver>;
type IntoIter = Iter<'a, Box<dyn ModuleResolver>>;
#[inline(always)]
fn into_iter(self) -> Self::IntoIter {
self.0.iter()
}
}
impl ModuleResolver for ModuleResolversCollection {
fn resolve(
&self,