EmbarkStudios / mirror-mirror

🪞 Powerful reflection library for Rust
Apache License 2.0
79 stars 2 forks source link

Optimize iterators to not allocate #3

Closed davidpdrsn closed 1 year ago

davidpdrsn commented 1 year ago

Currently most iterators like Struct::fields is defined as:

pub struct PairIter<'a, T = str>
where
    T: ?Sized,
{
    iter: Box<dyn Iterator<Item = (&'a T, &'a dyn Reflect)> + 'a>,
}

which requires allocating. That could be optimized. We could do that bevy_reflect does where traits have a field_at(index) and fields_len methods.