1
0
Fork 0
mirror of https://codeberg.org/icewind/vbsp.git synced 2026-06-03 10:44:07 +02:00

Merge pull request #7 from krakow10/ent-iter

impl IntoIterator for &Entities
This commit is contained in:
Robin Appelman 2025-02-14 20:55:20 +01:00 committed by GitHub
commit bdb6b003c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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