#Guarantee return type isn't const
1 messages · Page 1 of 1 (latest)
what's an example of a @constCast you're using?
i don't quite understand your question. types, and therefore return types, don't have an inherent constness.
what's the definition of widgets.Container?
pub fn Container(alloc: *std.mem.Allocator) protocol.NestedFrame {
return .{.children = std.ArrayList(protocol.NestedFrame).init(alloc.*), .callbacks = .{.event_handler = @constCast(&event_handler_container)}};
}
pub const NestedFrame = struct {
x: u32 = 0,
y: u32 = 0,
x_size: u32 = 0,
y_size: u32 = 0,
id: u64 = 0,
children: std.ArrayList(NestedFrame),
callbacks: FrameCallbacks,
};
I like doing a lot in one line, e.g. method chaining
can event_handler_container be changed from const to var?
It's a function pointer
Well zig does not support method chaining very well
then the .event_handler in callbacks should be const so that you do not need @constCast