impl IntoIterator for EntityList, so entities can be easily iterated

This commit is contained in:
mykola2312 2023-09-05 00:04:54 +03:00
parent 5f63a69c38
commit 201b51e85c
2 changed files with 12 additions and 0 deletions

View file

@ -159,3 +159,12 @@ impl DecoderCtx<EntityEncoding, EntityEncoding> for EntityList {
self.enc_size
}
}
impl<'a> IntoIterator for &'a EntityList {
type Item = &'a Entity;
type IntoIter = std::slice::Iter<'a, Entity>;
fn into_iter(self) -> Self::IntoIter {
self.ents.iter()
}
}

View file

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