Avoid copying iterator sources.
This commit is contained in:
@@ -116,8 +116,8 @@ def_package!(crate:BasicArrayPackage:"Basic array utilities.", lib, {
|
||||
// Register array iterator
|
||||
lib.type_iterators.insert(
|
||||
TypeId::of::<Array>(),
|
||||
Box::new(|a: &Dynamic| {
|
||||
Box::new(a.downcast_ref::<Array>().unwrap().clone().into_iter())
|
||||
Box::new(|a: Dynamic| {
|
||||
Box::new(a.cast::<Array>().into_iter())
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
}),
|
||||
);
|
||||
|
@@ -19,14 +19,9 @@ where
|
||||
{
|
||||
lib.type_iterators.insert(
|
||||
TypeId::of::<Range<T>>(),
|
||||
Box::new(|source: &Dynamic| {
|
||||
Box::new(
|
||||
source
|
||||
.downcast_ref::<Range<T>>()
|
||||
.cloned()
|
||||
.unwrap()
|
||||
.map(|x| x.into_dynamic()),
|
||||
) as Box<dyn Iterator<Item = Dynamic>>
|
||||
Box::new(|source: Dynamic| {
|
||||
Box::new(source.cast::<Range<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -64,14 +59,9 @@ where
|
||||
{
|
||||
lib.type_iterators.insert(
|
||||
TypeId::of::<StepRange<T>>(),
|
||||
Box::new(|source: &Dynamic| {
|
||||
Box::new(
|
||||
source
|
||||
.downcast_ref::<StepRange<T>>()
|
||||
.cloned()
|
||||
.unwrap()
|
||||
.map(|x| x.into_dynamic()),
|
||||
) as Box<dyn Iterator<Item = Dynamic>>
|
||||
Box::new(|source: Dynamic| {
|
||||
Box::new(source.cast::<StepRange<T>>().map(|x| x.into_dynamic()))
|
||||
as Box<dyn Iterator<Item = Dynamic>>
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user