authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-15 22:07:05 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-09-15 22:07:05 -07:00
logfde7165927efa40fb5ab392c171dcfb06396e5cb
treecad37090371d3d343fb1e360569c685babeeeaec
parente609abac9f01ff0f54ca928feb0bec165cd6eebf

add containsAggregate


1 files changed, 9 insertions(+), 0 deletions(-)

src/lib.zig+9
...@@ -680,3 +680,12 @@ pub fn ReverseFields(comptime T: type) type {...@@ -680,3 +680,12 @@ pub fn ReverseFields(comptime T: type) type {
680pub fn stringToEnum(comptime E: type, str: ?string) ?E {680pub fn stringToEnum(comptime E: type, str: ?string) ?E {
681 return std.meta.stringToEnum(E, str orelse return null);681 return std.meta.stringToEnum(E, str orelse return null);
682}682}
683
684pub fn containsAggregate(comptime T: type, haystack: []const T, needle: T) bool {
685 for (haystack) |item| {
686 if (T.eql(item, needle)) {
687 return true;
688 }
689 }
690 return false;
691}