File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ pub struct MemoryMapTag {
22
22
23
23
impl MemoryMapTag {
24
24
/// Return an iterator over all AVAILABLE marked memory areas.
25
- pub fn memory_areas ( & self ) -> MemoryAreaIter {
25
+ pub fn memory_areas ( & self ) -> impl Iterator < Item = & MemoryArea > {
26
+ self . all_memory_areas ( ) . filter ( |entry| entry. typ == 1 )
27
+ }
28
+
29
+ /// Return an iterator over all marked memory areas.
30
+ pub fn all_memory_areas ( & self ) -> MemoryAreaIter {
26
31
let self_ptr = self as * const MemoryMapTag ;
27
32
let start_area = ( & self . first_area ) as * const MemoryArea ;
28
33
MemoryAreaIter {
@@ -91,7 +96,7 @@ pub enum MemoryAreaType {
91
96
Defective ,
92
97
}
93
98
94
- /// An iterator over Available memory areas.
99
+ /// An iterator over all memory areas
95
100
#[ derive( Clone , Debug ) ]
96
101
pub struct MemoryAreaIter < ' a > {
97
102
current_area : u64 ,
@@ -108,9 +113,7 @@ impl<'a> Iterator for MemoryAreaIter<'a> {
108
113
} else {
109
114
let area = unsafe { & * ( self . current_area as * const MemoryArea ) } ;
110
115
self . current_area = self . current_area + ( self . entry_size as u64 ) ;
111
- if area. typ == 1 {
112
- Some ( area)
113
- } else { self . next ( ) }
116
+ Some ( area)
114
117
}
115
118
}
116
119
}
You can’t perform that action at this time.
0 commit comments