modify IntoIterator that now it yields (id, &Entity)

This commit is contained in:
mykola2312 2023-09-05 00:17:48 +03:00
parent 201b51e85c
commit 88003c2997
2 changed files with 7 additions and 7 deletions

View file

@ -26,8 +26,8 @@ pub struct EntityList {
unk1: u32,
enc_size: usize,
pub types: Vec<FString>,
pub ents: Vec<Entity>,
types: Vec<FString>,
ents: Vec<Entity>,
}
impl EntityList {
@ -161,10 +161,10 @@ impl DecoderCtx<EntityEncoding, EntityEncoding> for EntityList {
}
impl<'a> IntoIterator for &'a EntityList {
type Item = &'a Entity;
type IntoIter = std::slice::Iter<'a, Entity>;
type Item = (usize, &'a Entity);
type IntoIter = std::iter::Zip<std::ops::RangeFrom<usize>, std::slice::Iter<'a, Entity>>;
fn into_iter(self) -> Self::IntoIter {
self.ents.iter()
(1..).zip(&self.ents)
}
}

View file

@ -37,8 +37,8 @@ impl World {
self.entlist
.encode(EntityEncoding::File)?
.dump(Path::new("D:\\entlist.ent"))?;*/
for ent in &self.entlist {
println!("{}", ent.type_idx);
for (id, ent) in &self.entlist {
println!("{} {}", id, ent.type_idx);
}
Ok(())