Skip to content

Commit

Permalink
Fix 'write_from_data_end'
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Oct 17, 2023
1 parent b6a0a6e commit e19da10
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,27 +673,26 @@ impl<C: TableDataContent> Resource<C> {
let tag = BytesStart::borrowed_name(Self::TAG_BYTES);
let mut iter = self.sub_elems.iter_mut();
let mut table_found = false;
while !table_found {
if let Some(se) = iter.next() {
if match &mut se.resource_or_table {
ResourceOrTable::Resource(resource) => {
resource.write_from_data_end(writer, &(), start_after_data)
}
ResourceOrTable::Table(table) => table
.write_from_data_end(writer, &(), start_after_data)
.map(|()| true),
}? {
table_found = true;
for info in se.infos.iter_mut() {
info.write(writer, context)?;
}
while let Some(se) = iter.next() {
if match &mut se.resource_or_table {
ResourceOrTable::Resource(resource) => {
resource.write_from_data_end(writer, &(), start_after_data)
}
ResourceOrTable::Table(table) => table
.write_from_data_end(writer, &(), start_after_data)
.map(|()| true),
}? {
table_found = true;
for info in se.infos.iter_mut() {
info.write(writer, context)?;
}
break;
}
}
for se in iter {
se.write(writer)?;
}
if table_found {
for se in iter {
se.write(writer)?;
}
// Close tag
writer
.write_event(Event::End(tag.to_end()))
Expand Down

0 comments on commit e19da10

Please sign in to comment.