Add/remove #[inline] attributes.

This commit is contained in:
Stephen Chung
2020-10-08 22:25:50 +08:00
parent e34a370f33
commit 1272eeb81a
31 changed files with 328 additions and 114 deletions

View File

@@ -42,35 +42,43 @@ impl ModuleResolversCollection {
/// let mut engine = Engine::new();
/// engine.set_module_resolver(Some(collection));
/// ```
#[inline(always)]
pub fn new() -> Self {
Default::default()
}
/// Add a module keyed by its path.
#[inline(always)]
pub fn push(&mut self, resolver: impl ModuleResolver + 'static) {
self.0.push(Box::new(resolver));
}
/// Get an iterator of all the module resolvers.
#[inline(always)]
pub fn iter(&self) -> impl Iterator<Item = &dyn ModuleResolver> {
self.0.iter().map(|v| v.as_ref())
}
/// Get a mutable iterator of all the modules.
#[inline(always)]
pub fn into_iter(self) -> impl Iterator<Item = Box<dyn ModuleResolver>> {
self.0.into_iter()
}
/// Remove all module resolvers.
#[inline(always)]
pub fn clear(&mut self) {
self.0.clear();
}
/// Is this `ModuleResolversCollection` empty?
#[inline(always)]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
/// Get the number of module resolvers in this `ModuleResolversCollection`.
#[inline(always)]
pub fn len(&self) -> usize {
self.0.len()
}
/// Add another `ModuleResolversCollection` to the end of this collection.
/// The other `ModuleResolversCollection` is consumed.
#[inline(always)]
pub fn append(&mut self, other: Self) {
if !other.is_empty() {
self.0.extend(other.0.into_iter());
@@ -101,6 +109,7 @@ impl ModuleResolver for ModuleResolversCollection {
}
impl<M: ModuleResolver + 'static> AddAssign<M> for ModuleResolversCollection {
#[inline(always)]
fn add_assign(&mut self, rhs: M) {
self.push(rhs);
}