Reduce usage of as_ref and as_mut.
This commit is contained in:
@@ -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,
|
||||
|
@@ -172,7 +172,7 @@ impl FileModuleResolver {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn base_path(&self) -> Option<&Path> {
|
||||
self.base_path.as_ref().map(PathBuf::as_ref)
|
||||
self.base_path.as_ref().map(<_>::as_ref)
|
||||
}
|
||||
/// Set the base path for script files.
|
||||
#[inline(always)]
|
||||
|
@@ -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(
|
||||
|
Reference in New Issue
Block a user