Use function pointers for iterators.
This commit is contained in:
@@ -120,8 +120,6 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
|
||||
// Register array iterator
|
||||
lib.set_iter(
|
||||
TypeId::of::<Array>(),
|
||||
Box::new(|arr| Box::new(
|
||||
arr.cast::<Array>().into_iter()) as Box<dyn Iterator<Item = Dynamic>>
|
||||
),
|
||||
|arr| Box::new(arr.cast::<Array>().into_iter()) as Box<dyn Iterator<Item = Dynamic>>,
|
||||
);
|
||||
});
|
||||
|
@@ -14,13 +14,10 @@ fn reg_range<T: Variant + Clone>(lib: &mut Module)
|
||||
where
|
||||
Range<T>: Iterator<Item = T>,
|
||||
{
|
||||
lib.set_iter(
|
||||
TypeId::of::<Range<T>>(),
|
||||
Box::new(|source| {
|
||||
Box::new(source.cast::<Range<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
}),
|
||||
);
|
||||
lib.set_iter(TypeId::of::<Range<T>>(), |source| {
|
||||
Box::new(source.cast::<Range<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
});
|
||||
}
|
||||
|
||||
fn get_range<T: Variant + Clone>(from: T, to: T) -> FuncReturn<Range<T>> {
|
||||
@@ -58,13 +55,10 @@ where
|
||||
T: Variant + Clone + PartialOrd,
|
||||
StepRange<T>: Iterator<Item = T>,
|
||||
{
|
||||
lib.set_iter(
|
||||
TypeId::of::<StepRange<T>>(),
|
||||
Box::new(|source| {
|
||||
Box::new(source.cast::<StepRange<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
}),
|
||||
);
|
||||
lib.set_iter(TypeId::of::<StepRange<T>>(), |source| {
|
||||
Box::new(source.cast::<StepRange<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
});
|
||||
}
|
||||
|
||||
fn get_step_range<T>(from: T, to: T, step: T) -> FuncReturn<StepRange<T>>
|
||||
|
@@ -83,7 +83,7 @@ impl PackagesCollection {
|
||||
self.packages.iter().any(|p| p.contains_iter(id))
|
||||
}
|
||||
/// Get the specified TypeId iterator.
|
||||
pub fn get_iter(&self, id: TypeId) -> Option<&IteratorFn> {
|
||||
pub fn get_iter(&self, id: TypeId) -> Option<IteratorFn> {
|
||||
self.packages
|
||||
.iter()
|
||||
.map(|p| p.get_iter(id))
|
||||
|
Reference in New Issue
Block a user