Skip to content
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,25 @@ impl<'render, 'clay: 'render, ImageElementData: 'render, CustomElementData: 'ren
}
}

#[cfg(feature = "std")]
pub fn collect<'commands>(
&mut self,
) -> Vec<RenderCommand<'commands, ImageElementData, CustomElementData>> {
let array = unsafe { Clay_EndLayout() };
self.dropped = true;
let slice = unsafe { core::slice::from_raw_parts(array.internalArray, array.length as _) };
let mut commands =
Vec::<RenderCommand<'commands, ImageElementData, CustomElementData>>::new();
for command in slice.iter() {
commands.push(unsafe { RenderCommand::from_clay_render_command(*command) });
}

slice
.iter()
.map(|command| unsafe { RenderCommand::from_clay_render_command(*command) })
.collect::<Vec<RenderCommand<'commands, ImageElementData, CustomElementData>>>()
}

pub fn end(
&mut self,
) -> impl Iterator<Item = RenderCommand<'render, ImageElementData, CustomElementData>> {
Expand Down
Loading