File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,12 @@ impl PageTable {
208
208
/// Returns an iterator over the entries of the page table.
209
209
#[ inline]
210
210
pub fn iter ( & self ) -> impl Iterator < Item = & PageTableEntry > {
211
+ ( 0 ..512 ) . map ( move |i| & self . entries [ i] )
212
+ }
213
+
214
+ /// Returns an iterator that allows modifying the entries of the page table.
215
+ #[ inline]
216
+ pub fn iter_mut ( & mut self ) -> impl Iterator < Item = & mut PageTableEntry > {
211
217
// Note that we intentionally don't just return `self.entries.iter()`:
212
218
// Some users may choose to create a reference to a page table at
213
219
// `0xffff_ffff_ffff_f000`. This causes problems because calculating
@@ -222,14 +228,6 @@ impl PageTable {
222
228
// calculate the end pointer. This doesn't make creating page tables at
223
229
// that address sound, but it avoids some easy to trigger
224
230
// miscompilations.
225
- let ptr = self . entries . as_ptr ( ) ;
226
- ( 0 ..512 ) . map ( move |i| unsafe { & * ptr. add ( i) } )
227
- }
228
-
229
- /// Returns an iterator that allows modifying the entries of the page table.
230
- #[ inline]
231
- pub fn iter_mut ( & mut self ) -> impl Iterator < Item = & mut PageTableEntry > {
232
- // See `Self::iter`.
233
231
let ptr = self . entries . as_mut_ptr ( ) ;
234
232
( 0 ..512 ) . map ( move |i| unsafe { & mut * ptr. add ( i) } )
235
233
}
You can’t perform that action at this time.
0 commit comments