Rust 1.64.0 Released
Rust 1.64.0 was released on September 22nd 2022.
As always Rust can be updated by running
rustup upgrade stable
Highlights from this release are
Improvements to .await
and IntoFuture
⌗
These changes allow API implementers to provide cleaner APIs by directly converting their objects into futures when using the await
keyword.
use std::future::{Future, IntoFuture};
use std::pin::Pin;
struct AsyncResult {}
struct AsyncTask {}
impl AsyncTask {
fn new() -> Self {
AsyncTask{}
}
async fn send(self)
-> Result <AsyncResult, Box<dyn std::error::Error>> {
Ok(AsyncResult{})
//or fail
//Err("boom")?
}
}
type AsyncTaskError = Box<dyn std::error::Error>;
type AsyncTaskFuture = Pin<Box<dyn Future<Output = Result<AsyncResult, AsyncTaskError >> + Send +'static>>;
impl IntoFuture for AsyncTask {
type IntoFuture = AsyncTaskFuture;
type Output = <AsyncTaskFuture as Future>::Output;
fn into_future(self) -> Self::IntoFuture {
Box::pin(self.send())
}
}
#[tokio::main]
async fn main() {
// previously users had to invoke your async method
AsyncTask::new().send().await.expect("failed");
// Now users can await the object directly
AsyncTask::new().await.expect("failed");
}
rust-analyzer is now a rustup component⌗
This must-have utility was previously a standalone installation or installed via editor extension mechanism.
# install with
rustup component add rust-analyzer
#invoke with
rustup run stable rust-analyzer
Visit the Rust release blog post for more details and additional features of release 1.64.0
Read other posts