authorgravatar for hello@nektro.netMeghan <hello@nektro.net> 2022-04-26 21:53:21 -07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-04-26 21:53:21 -07:00
log13f985e368b9ff32f972282fe41faad2d60b6670
tree94ea34ae8a5e3b4eb986258e983c924b06d0efbb
parentb16f583d5af5c86c92237bf56fa8063a5e9961c3
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

add countScalar


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

src/lib.zig+11
...@@ -230,3 +230,14 @@ pub fn TagNameJsonStringifyMixin(comptime S: type) type {...@@ -230,3 +230,14 @@ pub fn TagNameJsonStringifyMixin(comptime S: type) type {
230 }230 }
231 };231 };
232}232}
233
234pub fn countScalar(comptime T: type, haystack: []const T, needle: T) usize {
235 var found: usize = 0;
236
237 for (haystack) |item| {
238 if (item == needle) {
239 found += 1;
240 }
241 }
242 return found;
243}