@@ -1990,8 +1990,11 @@ pub struct MemoryMapSize {
1990
1990
pub map_size : usize ,
1991
1991
}
1992
1992
1993
- /// An iterator of [`MemoryDescriptor`] which returns elements in sorted order. The underlying memory map is always
1994
- /// associated with the unique [`MemoryMapKey`] contained in the struct.
1993
+ /// An iterator of [`MemoryDescriptor`] that is always associated with the
1994
+ /// unique [`MemoryMapKey`] contained in the struct.
1995
+ ///
1996
+ /// To iterate over the entries, call [`MemoryMap::entries`]. To get a sorted
1997
+ /// map, you manually have to call [`MemoryMap::sort`] first.
1995
1998
pub struct MemoryMap < ' buf > {
1996
1999
key : MemoryMapKey ,
1997
2000
buf : & ' buf mut [ u8 ] ,
@@ -2007,6 +2010,7 @@ impl<'buf> MemoryMap<'buf> {
2007
2010
}
2008
2011
2009
2012
/// Sorts the memory map by physical address in place.
2013
+ /// This operation is optional and should be invoked only once.
2010
2014
pub fn sort ( & mut self ) {
2011
2015
unsafe {
2012
2016
self . qsort ( 0 , self . len - 1 ) ;
@@ -2075,8 +2079,9 @@ impl<'buf> MemoryMap<'buf> {
2075
2079
elem. phys_start
2076
2080
}
2077
2081
2082
+ /// Returns an iterator over the contained memory map. To get a sorted map,
2083
+ /// call [`MemoryMap::sort`] first.
2078
2084
#[ must_use]
2079
- /// Returns an iterator over the contained memory map
2080
2085
pub fn entries ( & self ) -> MemoryMapIter {
2081
2086
MemoryMapIter {
2082
2087
buffer : self . buf ,
@@ -2356,7 +2361,6 @@ mod tests {
2356
2361
}
2357
2362
2358
2363
// Added for debug purposes on test failure
2359
- #[ cfg( test) ]
2360
2364
impl core:: fmt:: Display for MemoryMap < ' _ > {
2361
2365
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
2362
2366
writeln ! ( f) ?;
0 commit comments