-
-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Description
hi, here is the code, and will compile for (A,), but can't compile for (A, B).
here is the code in the playgoround
use async_trait::async_trait;
struct Text;
#[async_trait]
trait FromText<'r> {
type Output;
async fn parse(text: &'r Text) -> Self::Output;
}
// can compile for (A,)
#[async_trait]
impl<'r, A> FromText<'r> for (A,)
where
A: FromText<'r>,
{
type Output = (A::Output,);
async fn parse(text: &'r Text) -> Self::Output {
let a = A::parse(text).await;
(a,)
}
}
// can't compile for (A, B)
#[async_trait]
impl<'r, A, B> FromText<'r> for (A, B)
where
A: FromText<'r>,
B: FromText<'r>,
A::Output: Send,
B::Output: Send,
{
type Output = (A::Output, B::Output);
async fn parse(text: &'r Text) -> Self::Output {
let a = A::parse(text).await;
let b = B::parse(text).await;
(a, b)
}
}the error message:
ompiling playground v0.0.1 (/playground)
error: lifetime may not live long enough
--> src/lib.rs:37:52
|
28 | impl<'r, A, B> FromText<'r> for (A, B)
| -- lifetime `'r` defined here
...
37 | async fn parse(text: &'r Text) -> Self::Output {
| ____________________________________________________^
38 | | let a = A::parse(text).await;
39 | | let b = B::parse(text).await;
40 | | (a, b)
41 | | }
| |_____^ cast requires that `'r` must outlive `'static`
Metadata
Metadata
Assignees
Labels
No labels