The document of the function connect() says it would return a Future.
This method will create a new TCP socket and attempt to connect it to the addr provided. The returned future will be resolved once the stream has successfully connected, or it will return an error if one occurs.
And from its signature, pub async fn connect<A: ToSocketAddrs>(addrs: A) -> io::Result<TcpStream>, the return value is of type std::io::Result and can be used with the 'await' syntax, such as let mut socket = async_std::net::TcpStream::connect((host, port)).await?;.
But I can't find the Future trait implementation of the type std::io::Result. My questions are:
- Does the std::io::Result implement the Future trait?
- If it doesn't implement the trait, why can we still apply the 'await' syntax on it?