Hello guys, I have to write a custom hash function on a specific type with strings in its fields, Here it's the type LayoutElement, as you can see their is a nested structure so it makes things difficult...
// The type I want to store as key of HashMap :
pub const LayoutElement = struct {
data: LayoutElementKind,
media_query: ?MediaQuery,
};
pub const LayoutElementKind = union(enum) {
component: Component,
utility: LayoutClass,
};
pub const Component = union(enum) {
box: Box,
center: Center,
};
pub const Box = struct {
max_width: []const u8 = "",
grow: bool = false,
};
pub const Center = struct {
max_width: []const u8 = "",
and_text: bool = false,
recursive: bool = false,
};
pub const LayoutClassName = enum(u32) {
//Component Attributes
max_width = 0,
grow,
and_text,
recursive,
// Utilities
pb = 100,
};
pub const LayoutClass = struct {
name: LayoutClassName,
value: []const u8,
};
pub const MediaQuery = union(enum) {
superior_to: struct { breakpoint: usize, value: []const u8 },
inferior_or_equal_to: struct { breakpoint: usize },
};```