我想编写一个复制任何类型列表的通用方法。我的代码:
copy_list(in_list : list of rf_type) : list of rf_type is {
var out_list : list of rf_type;
gen out_list keeping { it.size() == in_list.size(); };
for each (elem) in in_list {
out_list[index] = elem.unsafe();
};
result = out_list;
};
方法的调用:
var list_a : list of uint;
gen list_a;
var list_b : list of uint;
list_b = copy_list(list_a);
错误:
ERR_GEN_NO_GEN_TYPE: Type 'list of rf_type' is not generateable
(it is not a subtype of any_struct) at line ...
gen out_list keeping { it.size() == in_list.size(); };
此外,copy_list
使用以下方法定义方法时也会出错list of untyped
:
Error: 'list_a' is of type 'list of uint', while expecting
type 'list of untyped'.
你能帮忙写一个复制列表的通用方法吗?感谢您的任何帮助