}
case str {
- if to_parse.count == 0 do return false;
- if to_parse[0] != #char "\"" do return false;
+ if to_parse.count == 0 do return false;
+
+ dest := cast(&str) target;
+
+ // If the string does *look* like a quoted string,
+ // simply return a copy of the whole string.
+ if to_parse[0] != #char "\"" {
+ *dest = string.alloc_copy(to_parse, string_allocator);
+ return true;
+ }
+
+
line := to_parse;
string.advance(&line);
- dest := cast(&str) target;
*dest = string.read_until(&line, #char "\"") |> string.alloc_copy(string_allocator); // @BUG // This does not handle escaped strings!
return true;
}
Type_Info_Slice,
Type_Info_Dynamic_Array,
- get_struct_member
+ get_struct_member,
+ union_constructed_from
}
// Either to_any or as_any will work. I prefer `as_any` because
return v;
}
+#doc "Unwraps an optional any, if the any is an optional. `? T -> T`"
+any_unwrap :: (v: any) -> any {
+ if union_constructed_from(v.type, Optional) {
+ t := v.type->info()->as_union();
+ return any.{
+ cast([&] u8, v.data) + t.alignment,
+ t.variants[1].type
+ };
+ }
+
+ return v;
+}
+
#doc "Subscript an array-like any."
any_subscript :: (v: any, index: i32) -> any {