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:
commit
bdb6b003c6
1 changed files with 25 additions and 16 deletions
|
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue