• Rogue@feddit.uk
    link
    fedilink
    arrow-up
    16
    ·
    2 个月前

    For anyone like me who hasn’t seen an edition change before, it’s just a mechanism for bundling breaking changes together and making them opt-in.

    We are excited to announce that the Rust 2024 Edition is now stable! Editions are a mechanism for opt-in changes that may otherwise pose a backwards compatibility risk.

    • Aljaž Mur Eržen@fosstodon.org
      link
      fedilink
      arrow-up
      6
      ·
      2 个月前

      @Rogue @snaggen Yeah, it’s a setting in Cargo.toml that you have to update manually if you want to upgrade. It is set to latest edition in new projects. And the nice thing:

      it’s configurable per-crate, not per-compilation. So you can depend on crates that use different editions than your crate. Which avoids ecosystem fragmentation.

      • Rogue@feddit.uk
        link
        fedilink
        arrow-up
        2
        ·
        2 个月前

        it’s configurable per-crate, not per-compilation. So you can depend on crates that use different editions than your crate. Which avoids ecosystem fragmentation.

        Thanks! That pre-empted my next question of how quickly crates typically update to newer editions. I guess it doesn’t matter

        • taladar
          link
          fedilink
          arrow-up
          3
          ·
          2 个月前

          There is also cargo fix --edition which can update your code in a very conservative way automatically. The result might not be as idiomatic but errs on the side of having semantics that do not change.

  • calcopiritus@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    2 个月前

    The const hash map is huge. It was always a pain the have const/static hash maps. Specially since most use cases don’t need a DoS-resistant hash map. Will be migrating to 2024 as soon as possible.

  • sugar_in_your_tea
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    2 个月前

    Adds Future and IntoFuture to the prelude.

    Woo!

    std::env::set_var, std::env::remove_var… are now unsafe functions.

    That’s unfortunate. I understand why it’s unsafe, but it would be cool if they were atomic or something instead. I don’t really want to clutter code with unsafe for things that are technically safe in context (e.g. unit tests for config parsing).

    async closures

    Baller.

    Other cool stuff as usual, so I’ll be updating soon. Congrats on the release!

    Edit: Looks like they messed with default lifetimes on impl Trait, but the fix was easy enough. The upgrade was otherwise smooth. Good work!

    • BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      2 个月前

      They did consider making environment-manipulation functions atomic; the problem is that there’s simply no way to guarantee that everything that can manipulate your process’s environment is actually beholden to whatever atomic interface Rust provides. I could be misremembering, but I think there was even some discussion with glibc maintainers about whether this could be made safe, and the answer was basically “haha no.”