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 {
208208 /// Returns an iterator over the entries of the page table.
209209 #[ inline]
210210 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 > {
211217 // Note that we intentionally don't just return `self.entries.iter()`:
212218 // Some users may choose to create a reference to a page table at
213219 // `0xffff_ffff_ffff_f000`. This causes problems because calculating
@@ -222,14 +228,6 @@ impl PageTable {
222228 // calculate the end pointer. This doesn't make creating page tables at
223229 // that address sound, but it avoids some easy to trigger
224230 // 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`.
233231 let ptr = self . entries . as_mut_ptr ( ) ;
234232 ( 0 ..512 ) . map ( move |i| unsafe { & mut * ptr. add ( i) } )
235233 }
You can’t perform that action at this time.
0 commit comments