const std = @import("std");

pub fn short_type_name(comptime T: type) [:0]const u8 {
    const fullTypeName = @typeName(T);
    const last_index = std.mem.lastIndexOf(u8, fullTypeName, ".");
    if (last_index) |idx| {
        return fullTypeName[idx + 1 .. :0];
    }
    return fullTypeName;
}

pub fn dumpStructType(comptime T: type) void {
    const info = @typeInfo(T);

    switch (info) {
        .@"struct" => |s| {
            std.log.info("struct {{", .{});
            inline for (s.fields) |field| {
                std.log.info("  {s}: {s}", .{ field.name, @typeName(field.type) });
            }
            std.log.info("}}", .{});
        },
        else => {
            std.log.info("{s} is not a struct", .{@typeName(T)});
        },
    }
}
