fix: prevent panic on empty message receive

This commit is contained in:
CJ van den Berg 2024-04-05 21:26:46 +02:00
parent fbb5c8e200
commit 9a51d756ce

View file

@ -138,7 +138,8 @@ pub const message = struct {
} }
pub fn from(span: anytype) Self { pub fn from(span: anytype) Self {
return .{ .buf = span.base[0..span.len] }; const buf = if (span.len > 0) span.base[0..span.len] else &[_]u8{};
return .{ .buf = buf };
} }
pub fn to(self: *const Self, comptime T: type) T { pub fn to(self: *const Self, comptime T: type) T {