Sfoglia il codice sorgente

multiboot2: iterator fix (0.15.1)

Philipp Schuster 2 anni fa
parent
commit
9e54f63d66
4 ha cambiato i file con 19 aggiunte e 7 eliminazioni
  1. 1 1
      multiboot2/Cargo.toml
  2. 11 0
      multiboot2/Changelog.md
  3. 1 1
      multiboot2/src/lib.rs
  4. 6 5
      multiboot2/src/memory_map.rs

+ 1 - 1
multiboot2/Cargo.toml

@@ -6,7 +6,7 @@ Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the speci
 including full support for the sections of ELF-64. This library is `no_std` and can be
 used in a Multiboot2-kernel.
 """
-version = "0.15.0"
+version = "0.15.1"
 authors = [
     "Philipp Oppermann <dev@phil-opp.com>",
     "Calvin Lee <cyrus296@gmail.com>",

+ 11 - 0
multiboot2/Changelog.md

@@ -1,5 +1,16 @@
 # CHANGELOG for crate `multiboot2`
 
+## 0.15.1 (2023-03-18)
+- **BREAKING** `MemoryMapTag::all_memory_areas` was renamed to `memory_areas`
+  and now returns `MemoryAreaIter` instead of
+  `impl Iterator<Item = &MemoryArea>`. Experience showed that its better to
+  return the specific iterator whenever possible.
+- **BREAKING** `MemoryMapTag::memory_areas` was renamed to
+  `available_memory_areas`
+  (_Sorry for the breaking changes in a minor release, but I just stumbled upon
+  this und since the last breaking release was just yesterday, users have to
+  deal with changes anyway._)
+
 ## 0.15.0 (2023-03-17)
 - **BREAKING** MSRV is 1.56.1
 - **BREAKING** fixed lifetime issues: `VBEInfoTag` is no longer `&static`

+ 1 - 1
multiboot2/src/lib.rs

@@ -1257,7 +1257,7 @@ mod tests {
         assert_eq!(ElfSectionFlags::empty(), s8.flags());
         assert_eq!(ElfSectionType::StringTable, s8.section_type());
         assert!(s.next().is_none());
-        let mut mm = bi.memory_map_tag().unwrap().memory_areas();
+        let mut mm = bi.memory_map_tag().unwrap().available_memory_areas();
         let mm1 = mm.next().unwrap();
         assert_eq!(0x00000000, mm1.start_address());
         assert_eq!(0x009_FC00, mm1.end_address());

+ 6 - 5
multiboot2/src/memory_map.rs

@@ -22,14 +22,15 @@ pub struct MemoryMapTag {
 }
 
 impl MemoryMapTag {
-    /// Return an iterator over all AVAILABLE marked memory areas.
-    pub fn memory_areas(&self) -> impl Iterator<Item = &MemoryArea> {
-        self.all_memory_areas()
+    /// Return an iterator over all memory areas that have the type
+    /// [`MemoryAreaType::Available`].
+    pub fn available_memory_areas(&self) -> impl Iterator<Item = &MemoryArea> {
+        self.memory_areas()
             .filter(|entry| matches!(entry.typ, MemoryAreaType::Available))
     }
 
-    /// Return an iterator over all marked memory areas.
-    pub fn all_memory_areas(&self) -> impl Iterator<Item = &MemoryArea> {
+    /// Return an iterator over all memory areas.
+    pub fn memory_areas(&self) -> MemoryAreaIter {
         let self_ptr = self as *const MemoryMapTag;
         let start_area = self.first_area.as_ptr();