dtolnay / async-trait

Type erasure for async trait methods

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using self method in default implementation is not supported

stevenroose opened this issue · comments

I can't find an issue for this, but it seems that this example is not supported:

use async_trait::async_trait;

#[async_trait]
pub trait Test {
	async fn normal(&self) -> bool;

	async fn with_default(&self) -> bool {
		self.normal()
	}
}

For calling one async function from another async function, you need to use await (in general, not only inside async traits):

async fn with_default(&self) -> bool {
    self.normal().await
}

Is it correct that that makes the futures returned no longer Send?