1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn lessThanSlice(comptime T: type) fn (void, T, T) bool {
6 return struct {
7 fn f(_: void, lhs: T, rhs: T) bool {
8 const result = for (0..@min(lhs.len, rhs.len)) |i| {
9 if (lhs[i] < rhs[i]) break true;
10 if (lhs[i] > rhs[i]) break false;
11 } else false;
12 return result;
13 }
14 }.f;
15}
16
17test {
18 try std.testing.expect(lessThanSlice(string)({}, "mouse", "possum"));
19}
20test {
21 try std.testing.expect(!lessThanSlice(string)({}, "mouse", "kangaroo"));
22}
23test {
24 try std.testing.expect(!lessThanSlice(string)({}, "mouse", "mouse"));
25}