fix build errors

This commit is contained in:
falsycat 2025-04-02 23:10:32 +09:00
parent ee8d0cde34
commit fc303ba553
2 changed files with 19 additions and 13 deletions

View File

@ -4,17 +4,17 @@ const std = @import("std");
pub fn Digraph(comptime T: type, comptime lessThanFn: LessThanFunc(T)) type {
return struct {
///
const Node = T;
pub const Node = T;
/// A connection between 2 nodes.
/// e.g.) `Conn { .from = X, .to = Y }` => "X is connected to Y"
const Conn = struct { from: T, to: T, };
pub const Conn = struct { from: T, to: T, };
///
const ConnList = std.ArrayList(Conn);
pub const ConnList = std.ArrayList(Conn);
///
const Error = error {
pub const Error = error {
AlreadyConnected,
NotConnected,
};

View File

@ -3,16 +3,22 @@ const std = @import("std");
/// A container for all existing instances of T.
/// This is like a dedicated allocator for the type, T, with a refcount system.
pub fn Store(comptime T: type) type {
const VTable = struct {
udata: ?*anyopaque = null,
deinitItem: ?*fn (?*anyopaque, *T) void = null,
};
return struct {
///
const Item = T;
pub const Item = T;
///
pub const VTable = struct {
///
udata: ?*anyopaque = null,
///
deinitItem: ?*fn (?*anyopaque, *T) void = null,
};
/// A struct which holds an item and its reference count.
const Slot = struct {
pub const Slot = struct {
item : Item,
refcnt: usize,
@ -25,7 +31,7 @@ pub fn Store(comptime T: type) type {
};
///
const Error = error {
pub const Error = error {
DetectedItemLeak,
};
@ -36,14 +42,14 @@ pub fn Store(comptime T: type) type {
vtable: VTable,
///
slots : std.ArrayList(Slot),
slots : std.ArrayList(*Slot),
///
pub fn init(alloc: std.mem.Allocator, vtable: VTable) @This() {
return .{
.alloc = alloc,
.vtable = vtable,
.slots = std.ArrayList(Slot).init(alloc),
.slots = std.ArrayList(*Slot).init(alloc),
};
}
///