getSlice
Parameters
Source
Implementation
pub fn getSlice(self: *Data, key: Key, comptime S: type) ?Slice(S) {
const bytes = self.get(key, if (SavedData.DebugInfo == void) {} else .{
.name = @typeName(@typeInfo(S).pointer.child),
.kind = if (@typeInfo(S).pointer.sentinel() == null) .slice else .slice_with_sentinel,
});
if (bytes) |b| {
var data: Slice(S) = @ptrCast(@alignCast(b));
return if (@typeInfo(Slice(S)).pointer.sentinel()) |s|
data[0 .. data.len - 1 :s]
else
data;
}
return null;
}