1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use crate::Entry;
use crate::EntryId;
use crate::Wad;
use crate::WadSlice;
pub struct EntryIterator<'a> {
index: usize,
wad: &'a Wad,
}
impl<'a> EntryIterator<'a> {
pub(crate) fn new<'b>(wad: &'b Wad) -> EntryIterator<'b> {
EntryIterator { index: 0, wad }
}
}
impl<'a> Iterator for EntryIterator<'a> {
type Item = Entry<'a>;
fn next(&mut self) -> Option<Self::Item> {
if self.index < self.wad.len() {
self.index += 1;
return Some(unsafe {
self.wad.entry_unchecked(self.index - 1).unwrap()
});
} else {
return None;
}
}
}
pub struct IdIterator<'a> {
index: usize,
wad: &'a Wad,
}
impl<'a> IdIterator<'a> {
pub(crate) fn new<'b>(wad: &'b Wad) -> IdIterator<'b> {
IdIterator { index: 0, wad }
}
}
impl<'a> Iterator for IdIterator<'a> {
type Item = EntryId;
fn next(&mut self) -> Option<Self::Item> {
if self.index < self.wad.len() {
self.index += 1;
return Some(unsafe {
self.wad.entry_id_unchecked(self.index - 1)
});
} else {
return None;
}
}
}
pub struct SliceEntryIterator<'a> {
index: usize,
wad: &'a WadSlice<'a>,
}
impl<'a> SliceEntryIterator<'a> {
pub(crate) fn new<'b>(wad: &'b WadSlice) -> SliceEntryIterator<'b> {
SliceEntryIterator { index: 0, wad }
}
}
impl<'a> Iterator for SliceEntryIterator<'a> {
type Item = Entry<'a>;
fn next(&mut self) -> Option<Self::Item> {
if self.index < self.wad.len() {
self.index += 1;
return Some(unsafe {
self.wad.entry_unchecked(self.index - 1).unwrap()
});
} else {
return None;
}
}
}
pub struct SliceIdIterator<'a> {
index: usize,
wad: &'a WadSlice<'a>,
}
impl<'a> SliceIdIterator<'a> {
pub(crate) fn new<'b>(wad: &'b WadSlice) -> SliceIdIterator<'b> {
SliceIdIterator { index: 0, wad }
}
}
impl<'a> Iterator for SliceIdIterator<'a> {
type Item = EntryId;
fn next(&mut self) -> Option<Self::Item> {
if self.index < self.wad.len() {
self.index += 1;
return Some(unsafe {
self.wad.entry_id_unchecked(self.index - 1)
});
} else {
return None;
}
}
}