From 4440a97c5a3bc8dca03198dbe0d9474978aa8904 Mon Sep 17 00:00:00 2001 From: patrick-scho Date: Sun, 6 Apr 2025 16:21:23 +0200 Subject: [PATCH] change reencode to include return type as parameter --- src/main.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.zig b/src/main.zig index 2f7fd4c..7fe3b63 100644 --- a/src/main.zig +++ b/src/main.zig @@ -97,8 +97,8 @@ fn parse_enum(comptime E: type, buf: []const u8, base: u8) !E { } // https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding -fn reencode(text: []const u8) !PostText { - var result = try PostText.init(0); +fn reencode(comptime T: type, text: []const u8) !T { + var result = try T.init(0); const len = @min(text.len, 1024); // TODO: PostText length @@ -286,7 +286,7 @@ const Chirp = struct { const posts = try Db.posts(txn); post_id = try db.Prng.gen(posts.dbi, PostId); - const decoded_text = try reencode(text); + const decoded_text = try reencode(PostText, text); try posts.put(post_id, Post{ .id = post_id, .parent_id = parent_id, -- 2.50.1