| ... | ... | @@ -22,3 +22,11 @@ pub fn reduceNumber(alloc: *std.mem.Allocator, input: u64, comptime unit: u64, c |
| 22 | 22 | pub fn intToFloat(n: u64) f64 { |
| 23 | 23 | return @intToFloat(f64, n); |
| 24 | 24 | } |
| 25 | |
| 26 | pub fn addSentinel(alloc: *std.mem.Allocator, comptime T: type, input: []const T, comptime sentinel: T) ![:sentinel]const T { |
| 27 | var list = try std.ArrayList(T).initCapacity(alloc, input.len + 1); |
| 28 | try list.appendSlice(input); |
| 29 | try list.append(sentinel); |
| 30 | const str = list.toOwnedSlice(); |
| 31 | return str[0 .. str.len - 1 :sentinel]; |
| 32 | } |