| author | |
| committer | |
| log | 2d3aee0360eefcf5f5c51887a6b33316f83f7060 |
| tree | f3784842536581c2d1f0770dce2b968dfba35ca0 |
| parent | fecd95d8ec6f9a11ba03fd85b951dd11c33962cb |
1 files changed, 7 insertions(+), 0 deletions(-)
src/lib.zig+7| ... | @@ -461,3 +461,10 @@ pub fn nullifyS(s: ?string) ?string { | ... | @@ -461,3 +461,10 @@ pub fn nullifyS(s: ?string) ?string { |
| 461 | if (s.?.len == 0) return null; | 461 | if (s.?.len == 0) return null; |
| 462 | return s.?; | 462 | return s.?; |
| 463 | } | 463 | } |
| 464 | |||
| 465 | pub fn sliceTo(comptime T: type, haystack: []const T, needle: T) []const T { | ||
| 466 | if (std.mem.indexOfScalar(T, haystack, needle)) |index| { | ||
| 467 | return haystack[0..index]; | ||
| 468 | } | ||
| 469 | return haystack; | ||
| 470 | } |