authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-18 23:53:48 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-18 23:53:48 -08:00
log4474a8e92ad519afefaebeba75dd14e072f05be4
tree21de6d28051a7652658cc2867e0bb55120b42f47
parent00f6148ec410aa69823cefee6ca671afade50489

add compareFnField


2 files changed, 14 insertions(+), 0 deletions(-)

src/compareFnField.zig created+13
...@@ -0,0 +1,13 @@
1const std = @import("std");
2const extras = @import("./lib.zig");
3
4pub fn compareFnField(N: type, H: type, f: std.meta.FieldEnum(H)) fn (N, H) std.math.Order {
5 const S = struct {
6 pub fn compare(needle: N, row: H) std.math.Order {
7 if (needle < @field(row, @tagName(f))) return .lt;
8 if (needle > @field(row, @tagName(f))) return .gt;
9 return .eq;
10 }
11 };
12 return S.compare;
13}
src/lib.zig+1
...@@ -115,3 +115,4 @@ pub usingnamespace @import("./omit.zig");...@@ -115,3 +115,4 @@ pub usingnamespace @import("./omit.zig");
115pub usingnamespace @import("./swapMany.zig");115pub usingnamespace @import("./swapMany.zig");
116pub usingnamespace @import("./ManyArrayList.zig");116pub usingnamespace @import("./ManyArrayList.zig");
117pub usingnamespace @import("./compareFnBasic.zig");117pub usingnamespace @import("./compareFnBasic.zig");
118pub usingnamespace @import("./compareFnField.zig");