blob: 1fe5e5ef9438f2c9173546a48711e810c190b45c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//! Abstract Data Type over Sstr, Istr, Array
const value = @import("../value.zig");
const Value = value.Value;
pub fn isString(v: Value) bool {
if (value.sstr.check(v)) return true;
if (value.istr.check(v)) return true;
if (value.array.check(.str, v)) |_| return true;
return false;
}
pub fn getBytes(s: *const Value) []const u8 {
if (value.sstr.check(s.*)) return value.sstr.unpack(s);
if (value.istr.check(s.*)) return value.istr.unpack(s.*).bytes();
if (value.array.check(.str, s.*)) |arr_ptr| return arr_ptr.bytesRO();
s.dump();
@panic("This is not a string.");
}
|