-
Notifications
You must be signed in to change notification settings - Fork 301
Add post for 1.77 #1271
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add post for 1.77 #1271
Conversation
Co-authored-by: Kevin Reid <kpreid@switchb.org>
Co-authored-by: Eric Huss <eric@huss.org>
Co-authored-by: Kevin Reid <kpreid@switchb.org>
I think one of the biggest changes in 1.77 is rust-lang/rust#117703. We now support recursive async functions (as long as they use indirection), making the before: use async_recursion::async_recursion;
#[async_recursion]
async fn fib(n : u32) -> u32 {
match n {
0 | 1 => 1,
_ => fib(n-1).await + fib(n-2).await
}
}
// which expands to
use std::future::Future;
use std::pin::Pin;
fn fib(n: u32) -> Pin<Box<dyn Future<Output = u32> + Send>> {
Box::pin(async move {
match n {
0 | 1 => 1,
_ => fib(n - 1).await + fib(n - 2).await,
}
})
} after async fn fib(n : u32) -> u32 {
match n {
0 | 1 => 1,
_ => Box::pin(fib(n-1)).await + Box::pin(fib(n-2)).await
}
} By avoiding trait objects this should improve the runtime performance of such functions and avoids the "auto-trait bound" problem of |
This comment was marked as duplicate.
This comment was marked as duplicate.
Alright, I think this is now updated per all the feedback here. Thanks! |
Co-authored-by: Kevin Reid <kpreid@switchb.org>
Co-authored-by: Josh Stone <cuviper@gmail.com>
Co-authored-by: lcnr <rust@lcnr.de>
cc @rust-lang/release