Rust 2020: Growth

(Maybe I'm currently not a Rust pro, but) I completely disagreed with that. GAT is very important to me. In fact, I had to abandoned Rust for one of my hobbyist project and switch to Go because of it.

I have a rule when it comes to third-party component management: The core part of my code should not directly depend on third-party code, the dependency must be done through an interface layer (for Rust, it's Trait).

Take the project that I've abandoned for example, the file structure was like:

- src
   |
   +- thirdparty
   |      |
   |      + tokio // Adapter (Trait implementer) for Tokio
   |      + ....
   |
   +- application
   |      |
   |      + application.rs
   |      + network_io_traits.rs // Including all the traits which tokio adapter will have to implement
   |      + ...
   |
   +- main.rs

When applied that rule, all my code under /application folder should not mention anything outside of it (except for std::*, of course).

Usually, it play along very well through heavy use of Trait Associated Types. Because with Associated Types, you don't have to concrete traits types.

However, things can quickly go down to nightmare as soon as lifetime decide to coming to play, as currently you cannot declare lifetime for Associated Types. Which closed down many possibilities in terms of lifetime and structural management.

Also, async trait and impl Trait in trait fn return position is something too nice to be missed.

So, I'd say writing Rust without GAT is just like eating scrambled eggs without egg yolk, something is left to be satisfied.

2 Likes