Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add post for 1.77 #1271

Merged
merged 10 commits into from
Mar 21, 2024
Merged

Add post for 1.77 #1271

merged 10 commits into from
Mar 21, 2024

Conversation

Mark-Simulacrum
Copy link
Member

cc @rust-lang/release

posts/2024-03-21-Rust-1.77.0.md Outdated Show resolved Hide resolved
posts/2024-03-21-Rust-1.77.0.md Outdated Show resolved Hide resolved
posts/2024-03-21-Rust-1.77.0.md Outdated Show resolved Hide resolved
posts/2024-03-21-Rust-1.77.0.md Outdated Show resolved Hide resolved
Mark-Simulacrum and others added 3 commits March 10, 2024 19:58
Co-authored-by: Kevin Reid <kpreid@switchb.org>
Co-authored-by: Eric Huss <eric@huss.org>
Co-authored-by: Kevin Reid <kpreid@switchb.org>
@lcnr
Copy link
Contributor

lcnr commented Mar 11, 2024

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 async-recursion crate unnecessary.

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 async-recursion by leaking the Send bound (and all other auto traits) automatically.

@slanterns

This comment was marked as duplicate.

@Mark-Simulacrum
Copy link
Member Author

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>
@Mark-Simulacrum Mark-Simulacrum merged commit 405e6a1 into rust-lang:master Mar 21, 2024
3 checks passed
@Mark-Simulacrum Mark-Simulacrum deleted the 1.77.0 branch March 21, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants