refactor: add WidgetList.delete function

This commit is contained in:
CJ van den Berg 2024-12-11 20:43:32 +01:00
parent d08737c0fe
commit 3cb1fc2bba
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -108,6 +108,10 @@ pub fn swap(self: *Self, n: usize, w: Widget) Widget {
return old.widget; return old.widget;
} }
pub fn delete(self: *Self, n: usize) void {
self.widgets.orderedRemove(n).widget.deinit(self.allocator);
}
pub fn replace(self: *Self, n: usize, w: Widget) void { pub fn replace(self: *Self, n: usize, w: Widget) void {
const old = self.swap(n, w); const old = self.swap(n, w);
old.deinit(self.allocator); old.deinit(self.allocator);