mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: support typeof[ T ]().idx and typeof[ T ]().name, where T can be any type, including ![]&string
(#16513)
This commit is contained in:
@ -196,13 +196,13 @@ fn (e &Encoder) encode_struct[U](val U, level int, mut wr io.Writer) ! {
|
||||
}
|
||||
} else {
|
||||
match field.unaliased_typ {
|
||||
string_type_idx {
|
||||
typeof[string]().idx {
|
||||
e.encode_string(val.$(field.name).str(), mut wr)!
|
||||
}
|
||||
int_type_idx {
|
||||
typeof[int]().idx {
|
||||
wr.write(val.$(field.name).str().bytes())!
|
||||
}
|
||||
byte_array_type_idx {
|
||||
typeof[[]byte]().idx {
|
||||
//! array
|
||||
e.encode_array(val.$(field.name), level, mut wr)!
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
module json2
|
||||
|
||||
fn gen_workaround[T](result T) T {
|
||||
return result
|
||||
}
|
||||
|
||||
fn gen_workaround_result[T](result T) ?T {
|
||||
return result
|
||||
}
|
||||
|
||||
fn gen_workaround_optional[T](result T) !T {
|
||||
return result
|
||||
}
|
||||
|
||||
const (
|
||||
string_type_idx = typeof(gen_workaround[string](unsafe { nil })).idx
|
||||
result_string_type_idx = typeof(gen_workaround_result[string](unsafe { nil })).idx
|
||||
optional_string_type_idx = typeof(gen_workaround_optional[string](unsafe { nil })).idx
|
||||
|
||||
int_type_idx = typeof(gen_workaround[int](unsafe { nil })).idx
|
||||
result_int_type_idx = typeof(gen_workaround_result[int](unsafe { nil })).idx
|
||||
optional_int_type_idx = typeof(gen_workaround_optional[int](unsafe { nil })).idx
|
||||
|
||||
int_array_type_idx = typeof(gen_workaround[[]int](unsafe { nil })).idx
|
||||
result_int_array_type_idx = typeof(gen_workaround_result[[]int](unsafe { nil })).idx
|
||||
optional_int_array_type_idx = typeof(gen_workaround_optional[[]int](unsafe { nil })).idx
|
||||
|
||||
byte_array_type_idx = typeof(gen_workaround[[]byte](unsafe { nil })).idx
|
||||
result_byte_array_type_idx = typeof(gen_workaround_result[[]byte](unsafe { nil })).idx
|
||||
optional_byte_array_type_idx = typeof(gen_workaround_optional[[]byte](unsafe { nil })).idx
|
||||
)
|
Reference in New Issue
Block a user