add support for expr
clouds56 opened this issue · 1 comments
clouds56 commented
make things like work
#[derive(Delegate)]
#[delegate(MyTrait, target = "self.0.lock().unwrap()")]
pub struct Wrapper(Arc<Mutex<State>>);
or consider backward compatibility
#[derive(Delegate)]
#[delegate(MyTrait, method = "inner")]
pub struct Wrapper(Arc<Mutex<State>>);
impl Wrapper {
fn inner(&self) -> MutexGuard<'_, State> {
self.0.lock().wrapper()
}
}
cameronbraid commented
I was hoping that #33 would allow me to do delegation like the following (similar to above example)
#[derive(Debug)]
pub struct RwLockMockProductDaoImpl(tokio::sync::RwLock<MockProductDaoImpl>);
#[async_trait]
impl ProductDaoDelegate for RwLockMockProductDaoImpl {
async fn get_for_id(&self, id: i64) -> Result<Option<ProductModel>> {
let guard = self.0.read().await;
guard.get_for_id(id).await
}
}
However I am unable to work it out.
Is someone able to given an example of delegating to a new type that wraps a tokio::sync::RwLock