Closed somewheve closed 4 years ago
I was not able to reproduce this so I think the error is somewhere else. Here is what I tried, which compiles correctly. In the future you should provide a minimal repro when opening an issue.
use async_trait::async_trait;
use std::error::Error;
#[async_trait]
trait Operation {
async fn insert_into_ck(&self, data: Vec<String>) -> Result<(), Box<dyn Error>>;
}
struct Ck<'a> {
ck_pool: Option<&'a Pool>,
}
struct Pool;
impl Pool {
async fn get_handle(&self) {}
}
#[async_trait]
impl Operation for Ck<'_> {
async fn insert_into_ck(&self, data: Vec<String>) -> Result<(), Box<dyn Error>> {
if self.ck_pool.is_none() {
panic!("请先调用init_ck初始化数据库连接池或者检查地址参数是否出错")
}
if let Some(pool) = &self.ck_pool {
let mut client = pool.get_handle().await;
}
Ok(())
}
}
Sorry I will give a reply tomorrow. I will check my code first, thanks for your code
.
caused by I write a function in a bad way
trait Operation {
async fn insert_into_ck(&self, data: Vec<String>)
}
My mistake。 thanks
will return a bad error
I don't get any message to specify the return value in the readme, It makes me feel sad. but got the
Any number of arguments, any return value;