1. 34
  1. 15

    This lead me to the docs for std::f32::total_cmp(), which has the following brilliant example code:

    struct GoodBoy {
        name: String,
        weight: f32,
    let mut bois = vec![
        GoodBoy { name: "Pucci".to_owned(), weight: 0.1 },
        GoodBoy { name: "Woofer".to_owned(), weight: 99.0 },
        GoodBoy { name: "Yapper".to_owned(), weight: 10.0 },
        GoodBoy { name: "Chonk".to_owned(), weight: f32::INFINITY },
        GoodBoy { name: "Abs. Unit".to_owned(), weight: f32::NAN },
        GoodBoy { name: "Floaty".to_owned(), weight: -5.0 },
    bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
    1. 9

      I’m really excited about releases like these. It’s just “finishing” the language and not adding any new features conceptually, just making it all more cohesive. The lack of Enum default derive is one of those things I run into rarely, but adding it in now reduces the conceptual overhead of Rust since deriving default now works on both Enums and Structs.

      I also think this shows the benefit of Rust’s release model, which is that smaller fixes and stabilizations can be made over time, and don’t have to be part of a larger release. I’m curious how the potential Rust stabilization in GCC affects things, especially when smaller fixes in a release like this might be nice in older versions of Rust (and as far as I know GCC is targeting an older Rust version).

      1. 10

        Rust has a fixed 6-week release train model. Nobody decides which release is going to be small or not. When stuff is ready, it lands.

        Once in a while a large feature that took years to develop lands, and people freak out and proclaim that Rust is changing to fast and rushing things, as if it invented and implemented every feature in 6 weeks.

        In this release: cargo add feature request was filed 8 years ago. Implementation issue has been opened 4 years ago. It waited for a better TOML parser/serializer to be developed, and once that happened, the replacement work started 5 months ago.

        1. 2

          a better TOML parser/serializer

          This piques my interest. What library is this? Does it maintain comments/formatting?

          1. 3

            The crate is toml_edit, and it does preserve comments and (most) formatting.

            Maybe something to format Cargo.toml files could be helpful as well?

        2. 1

          I’m curious how the potential Rust stabilization in GCC affects things

          What do you mean? The gcc-rs project? I’d hope it doesn’t affect mainline Rust at all.

          1. 2

            Yeah the gcc-rs project. I wonder about certain stabilizations in later versions of Rust which are very easily added to earlier versions of Rust built by gcc-rs. I don’t think it will affect mainline Rust, but if certain nice-to-haves, or more importantly unsound fixes, are backported for gcc-rs that could cause an unfortunate schism in the ecosystem.

            I haven’t seen or heard of anything indicating this might happen, but with multiple implementations in-use I do think it is something that will eventually occur (especially for safety-related and unsound concerns)

          2. 1

            I have never liked the idea of a Default trait or typeclass. Default with respect to what operation? Most times people want defaulting, they seem to have some kind of monoidal operation in mind.

            1. 10

              Default with respect to what operation?

              Initialization right? I don’t see how one would use the trait for any other operation. To me it seems quite natural that a number has a “reasonable default” (0) as well as a string (""). It’s not like the language forces you to use Default in case you have other defaults in mind.

          3. 4

            You can now add new dependencies directly from the command line using cargo add

            Excited to use this! For context, you previously had to use another crate (cargo-edit) that implemented this feature

            1. 3

              This really should just be the job of auto-completion in Cargo.toml. For IntelliJ, I believe it has been working for years. For rust-analyzer, we didn’t get to supporting Cargo.toml properly.

              1. 1

                And if you want an ergonomic feature enablement or the ability to remove dependencies, you still need cargo-edit.

              2. 3

                The mutex overhaul issue is very in-detail about various implementations and problems. For example the rabbit hole of priority inheritance with mutex contention.