What's the lifetime '_ equals

does 1 == 2 == 3 ? why? help thank you

pub trait Future {
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
}
pub trait Future {
    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output>;
}
pub trait Future {
    fn poll<'a, 'b>(self: Pin<&'a mut Self>, cx: &'b mut Context<'b>) -> Poll<Self::Output>;
}

No

1 == 2 != 3

The full desugaring is

pub trait Future {
    fn poll<'a, 'b, 'c>(self: Pin<&'a mut Self>, cx: &'b mut Context<'c>) -> Poll<Self::Output> where 'c: 'b;
}
4 Likes

Where can I find the relevant documents about this? thank you

You can find it here

https://doc.rust-lang.org/reference/lifetime-elision.html

If you need more, the keyword is lifetime elision

2 Likes

:sweat_smile: I only find this but...

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.