"@" in match tree?

impl<A: Future> Future for Fuse<A> {

    type Item = A::Item;

    type Error = A::Error;

    fn poll(&mut self) -> Poll<A::Item, A::Error> {

        let res = self.future.as_mut().map(|f| f.poll());

        match res.unwrap_or(Ok(Async::NotReady)) {

            res @ Ok(Async::Ready(_)) |

            res @ Err(_) => {

                self.future = None;

                res

            }

            Ok(Async::NotReady) => Ok(Async::NotReady)

        }

    }

}

what does "@" here use for?

Basically when you see res @ Ok(Async::Ready(_)) in a match statement, it will match if the expression after the @ matches, but res will be a variable containing the matched value, in this case it would have the value Ok(Async::Ready(something)),

2 Likes