Skip to content

Commit

Permalink
examples: ral1243 - fix Memory::free_exrom_slots to not underreport t…
Browse files Browse the repository at this point in the history
…he count, change Memory::attach_exroms to return a count
  • Loading branch information
royaltm committed Feb 25, 2024
1 parent aa45264 commit 552020e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/ral1243/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ impl Memory {
}
/// Return a number of `EX-ROM` slots that can still be populated.
pub fn free_exrom_slots(&self) -> usize {
u8::max_value() as usize - self.exroms.len()
(u8::max_value() as usize + 1) - self.exroms.len()
}
/// Attach `EX-ROMS` from the given `exroms` collection.
///
/// **Panics** if there is no more room for `exroms`.
pub fn attach_exroms<I>(&mut self, exroms: I)
/// Return the number of inserted `EX-ROMS`.
pub fn attach_exroms<I>(&mut self, exroms: I) -> usize
where I: IntoIterator<Item=Rom>,
I::IntoIter: ExactSizeIterator
{
Expand All @@ -92,6 +91,7 @@ impl Memory {
for exrom in exroms.take(max_exroms) {
self.attach_exrom(exrom);
}
max_exroms
}
/// Attach a given `EX-ROM`. Return a total number of inserted `EX-ROMS`.
///
Expand Down

0 comments on commit 552020e

Please sign in to comment.