Hacker News new | ask | show | jobs
by estebank 1034 days ago
Thank you for the list! That's useful for me to understand what we might not be actively working on that people find frustrating.

- Async traits: coming soon https://blog.rust-lang.org/inside-rust/2023/05/03/stabilizin..., actively in development (and has been for a while now, please don't confuse "this problem is hard and taking a long time" with "we don't care about this problem" https://github.com/rust-lang/rust/issues?q=is%3Aissue+label%...).

- async `Drop`: there have been multiple "false-starts", trying to come up with an acceptable design. We don't have a good answer for this at the moment. It is unknown to me how long it might take for us to figure it out.

- TAITs: same as async traits. It'll likely land after async fn in traits, but it's part of the same design and implementation effort.

- variadic generics (unlikely they will every be implemented): agree with your assessment, at least in the short to medium term.

- generic closures: same as above.

- optional/named parameters: I believe that this feature as such might never exist in rust but think that a combination of structural structs (`struct { bar: usize, baz: usize }`) and/or struct literal inference (`let x: S = _ { bar: 1, baz: 2 }`) and default const values in structs (`struct S { foo: usize = 42, bar: usize }`/`S { bar: 0, .. }`) would be more generally useful and would nicely cater to this use case (`foo(_ { bar: 42, .. }`).

- anonymous enums: I want this as well, but it interacts poorly with type parameters and automatic type upcasting (if you have `A | B` can you convert it into `A | B | C`? Does it need syntax? What about `Result<(), ()> | Option<()> | Result<i32, ()>`? If you have a function that returns that, what does `return Err(())` do?). Type downcasting could be done by forcing a match expression on the value. Whether `A | B` should `impl T` if `A: T, B: T` is an open question. I want to push for a solution here in the coming year.

2 comments

> TAITs

I personally find these 4 letter acronyms difficult to lookup and understand. One of the T is probably "trait", but I always forget.

Sorry, the names we use within the team are not meant to be used in user facing communications, but it is easy to forget that not everyone I talk to isn't in the team :)

TAIT stands for `type Alias = impl Trait;`, which would let you do something like

    type Alias = impl Display;
    fn foo() -> Alias {
        42
    }
    fn bar() -> Alias {
        0
    }
    fn main() {
        let x: Alias = if rand() > .5 {
            foo()
        } else {
            bar()
        };
    }
If you changed bar to return a &str, for example, that would be a compile error.

There's also the related

- RPIT, "return position impl trait" (we already have this)

- RPITIT, "return position impl trait in traits" (the foundation for async unctions in traits, `trait T { fn foo() -> impl Trait; }`)

- AFIT, "async functions in traits"

No, you shouldn't need to know what these things mean, beyond them "just working" in terms of what you would expect from writing impl Trait in different places.

Thanks for your comprehensive answer, it's really nice to see that async traits and etc. might be coming soon.