我想将一个函数转发到另一个模块中的一个方法,而不重复所有类型注释,也不需要手动传递参数。我该怎么做?
mod other_mod;
static client: other_mod::Client = other_mod::Client::new();
async fn search = client.search; // How to do this here?
Run Code Online (Sandbox Code Playgroud)
mod other_mod:
pub struct Client();
impl Client {
pub fn new() -> Self {
Self()
}
pub async fn search(&self, query: &str) -> Result<Vec<SearchResultItem>> { ... }
}
Run Code Online (Sandbox Code Playgroud)
在 Rust 中没有办法做到这一点。
| 归档时间: |
|
| 查看次数: |
296 次 |
| 最近记录: |