You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use async_trait::async_trait;structText;#[async_trait]traitFromText<'r>{typeOutput;asyncfnparse(text:&'r Text) -> Self::Output;}// can compile for (A,)#[async_trait]impl<'r,A>FromText<'r>for(A,)whereA:FromText<'r>,{typeOutput = (A::Output,);asyncfnparse(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)whereA:FromText<'r>,B:FromText<'r>,A::Output:Send,B::Output:Send,{typeOutput = (A::Output,B::Output);asyncfnparse(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`
The text was updated successfully, but these errors were encountered:
please use special lifetime 'async_trait, instead of 'r in declaration your trait FromText
to mark out the input text is always outlive in whole parse async blocks.
hi, here is the code, and will compile for
(A,)
, but can't compile for(A, B)
.here is the code in the playgoround
the error message:
The text was updated successfully, but these errors were encountered: