1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 18:54:05 +02:00

impl IntoIterator for &Entities

This commit is contained in:
Quaternions 2025-02-06 08:55:20 -08:00
commit 011260e360

View file

@ -26,14 +26,11 @@ impl fmt::Debug for Entities {
.fmt(f)
}
}
impl Entities {
pub fn iter(&self) -> impl Iterator<Item = RawEntity<'_>> {
struct Iter<'a> {
pub struct EntitiesIter<'a> {
buf: &'a str,
}
impl<'a> Iterator for Iter<'a> {
impl<'a> Iterator for EntitiesIter<'a> {
type Item = RawEntity<'a>;
fn next(&mut self) -> Option<Self::Item> {
@ -48,7 +45,19 @@ impl Entities {
}
}
Iter {
impl<'a> IntoIterator for &'a Entities {
type Item = RawEntity<'a>;
type IntoIter = EntitiesIter<'a>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
impl Entities {
pub fn iter(&self) -> EntitiesIter {
EntitiesIter {
buf: &self.entities,
}
}