this post was submitted on 20 Feb 2025
56 points (96.7% liked)

Programming

18337 readers
433 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

Finally the new Rust 1.85.0 update is here, with a new Rust Edition 2024.

top 9 comments
sorted by: hot top controversial new old
[โ€“] FizzyOrange 8 points 1 day ago

So glad they made the sane move and fixed std::env::home_dir(). The previous situation of having it deprecated due to fairly insignificant reasons, while recommending an abandoned crate instead was just silly.

[โ€“] [email protected] 7 points 1 day ago (1 children)

The gen keyword is too much teasing, I know it's not round the corner but I'm gonna explode ๐Ÿฅบ

[โ€“] BB_C 8 points 23 hours ago (1 children)

In case the wording tripped anyone, generators (blocks and functions) have been available for a while as an unstable feature.

This works (playground):

#![feature(gen_blocks)]

gen fn gfn() -> i32 {
    for i in 1..=10 {
        yield i;
    }
}

fn gblock() -> impl Iterator<Item = i32> {
    gen {
        for i in 1..=10 {
            yield i;
        }
    }
}

fn main() {
    for i in gfn() {
        println!("{i} from gfn()");
    }
    for i in gblock() {
        println!("{i} from gblock()");
    }
}

Note that the block-in-fn version works better at this moment (from a developer's PoV) because rust-analyzer currently treats gfn() as an i32 value. But the block-in-fn pattern works perfectly already.

[โ€“] [email protected] 1 points 10 hours ago

Amazing! Thanks for that. I didn't know this was actually available to play with.

[โ€“] [email protected] 8 points 1 day ago

Honestly, kind of most excited about std::env::home_dir() being fixed/undeprecated. That's the kind of thing that some languages would leave unfixed for eternity, until half the community recommends not using the stdlib even for basic uses.

[โ€“] livingcoder 5 points 1 day ago

I love the async closure update and the if-let scoping fix.

[โ€“] [email protected] 1 points 1 day ago (2 children)
[โ€“] [email protected] 3 points 1 day ago

It was mentioned in the notes for 1.84.0 that they began migrating to it. They might be doing it without an edition change if it's backwards compatible (or if the incompatibilities are considered bugs).

[โ€“] [email protected] 2 points 1 day ago

Road to 2027 then?