#[serde(rename)] 似乎是正确的选择,但文档未说明是否可行或如何执行。
此JSON对象:
{
"name" : "myobject"
"info" :
{
"counter" : "3"
"foo" : "bar"
}
}
Run Code Online (Sandbox Code Playgroud)
相应的Flat Rust结构应为:
#[derive(Deserialize)]
struct Object {
name: String,
#[serde(rename="info.counter")] // wrong syntax here !!
count: i32,
#[serde(rename="info::foo")] // neither this works
foo: String,
}
Run Code Online (Sandbox Code Playgroud) 我的问题如下.这是我的方法:
template<class T>
T my_function();
Run Code Online (Sandbox Code Playgroud)
这些专业可行:
template<>
int my_function(); //my_function<int>();
template<>
float my_function(); //my_function<flot>();
...
Run Code Online (Sandbox Code Playgroud)
但这些不是:
1.
template<>
template<class T>
std::list<T> my_function(); //my_function<std::list<class T> >();
Run Code Online (Sandbox Code Playgroud)
2.
template<class T>
template<>
std::vector<T> my_function(); //my_function<std::vector<class T> >();
Run Code Online (Sandbox Code Playgroud)
我收到错误:
too many template-parameter-lists
Run Code Online (Sandbox Code Playgroud)
所以我的问题是: 如何使用模板类专门化模板?