| author | |
| committer | |
| log | 4474a8e92ad519afefaebeba75dd14e072f05be4 |
| tree | 21de6d28051a7652658cc2867e0bb55120b42f47 |
| parent | 00f6148ec410aa69823cefee6ca671afade50489 |
2 files changed, 14 insertions(+), 0 deletions(-)
src/compareFnField.zig created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const extras = @import("./lib.zig"); | ||
| 3 | |||
| 4 | pub 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"); |
| 115 | pub usingnamespace @import("./swapMany.zig"); | 115 | pub usingnamespace @import("./swapMany.zig"); |
| 116 | pub usingnamespace @import("./ManyArrayList.zig"); | 116 | pub usingnamespace @import("./ManyArrayList.zig"); |
| 117 | pub usingnamespace @import("./compareFnBasic.zig"); | 117 | pub usingnamespace @import("./compareFnBasic.zig"); |
| 118 | pub usingnamespace @import("./compareFnField.zig"); |