Allow `pilota.rust_type` annotation work on container type
Feature Request
Motivation
Right now in pilota, when I wrote like this:
struct A {
1: required map<i32, string> m,
}
It will generate:
pub struct A {
pub m: ::std::collections::HashMap<i32, ::pilota::FastStr>,
}
And there is no other way to generate code like followings as pilota.rust_type annotation cannot work on container type.
pub struct A {
pub m: ::std::collections::HashMap<i32, String>,
}
是否可以在这两种方案中选择一个解决: 1、添加配置项可以指定是否使用FastStr生成的数据类型,毕竟FastStr为了解决性能问题,可以让使用者进行取舍。 2、在faststr库中对annotation进行适配。 或者有什么巧妙的解决方法?
@liuxin231 如果你需要用 String,直接 to_string 就好了?
@liuxin231 如果你需要用 String,直接 to_string 就好了?
@PureWhiteWu 我理解的这个问题是在生成代码时使用了FastStr,而不是std中的String,这样导致自定义添加一些注解时无法工作,不知道是不是这样?
不是,这个只是一个例子,这个 issue 要讨论的内容是说,目前我们没有一个很好的方案给 container type 里面的元素加注解。
tonic_build::configure() .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
类似这种?
@liuxin231 不是的,主要还是指通过不同的注解,让它可以作用到容器里面的类型。比如 pilota.rust_type_container