Things you can’t do in Rust (and what to do instead)

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • rust

    Empowering everyone to build reliable and efficient software.

  • Overall this is a great blog post that highlights many of the things newcomers to Rust try out or are surprised why they are so hard and discouraged. One nit:

    > Luckily there are some crates that take the solution and present a safe interface, such as the rental and once_self_cell crates.

    Please don't link to the rental crate any more, as it's out of maintenance. The github repo is archived [0] and the maintainer explicitly stated they don't want to hand over maintenance to someone else. Thankfully the maintainer was still available to implement one tiny patch recently to make it not fire a future compat lint [1], but given this announcement by the maintainer, generally I'd recommend people to move to maintained alternatives. Especially new projects should build on something else. Instead of rental, the blog post could mention ouroboros. Also as a nit, the once_self_cell crate has been renamed to self_cell. There is also selfstack but I haven't used it so don't know how good it is.

    [0]: https://github.com/jpernst/rental/commit/213671ab3aab3452efd...

    [1]: https://github.com/rust-lang/rust/issues/84428

  • rental

    Discontinued Rust macro to generate self-referential structs

  • Overall this is a great blog post that highlights many of the things newcomers to Rust try out or are surprised why they are so hard and discouraged. One nit:

    > Luckily there are some crates that take the solution and present a safe interface, such as the rental and once_self_cell crates.

    Please don't link to the rental crate any more, as it's out of maintenance. The github repo is archived [0] and the maintainer explicitly stated they don't want to hand over maintenance to someone else. Thankfully the maintainer was still available to implement one tiny patch recently to make it not fire a future compat lint [1], but given this announcement by the maintainer, generally I'd recommend people to move to maintained alternatives. Especially new projects should build on something else. Instead of rental, the blog post could mention ouroboros. Also as a nit, the once_self_cell crate has been renamed to self_cell. There is also selfstack but I haven't used it so don't know how good it is.

    [0]: https://github.com/jpernst/rental/commit/213671ab3aab3452efd...

    [1]: https://github.com/rust-lang/rust/issues/84428

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • sccache

    Sccache is a ccache-like tool. It is used as a compiler wrapper and avoids compilation when possible. Sccache has the capability to utilize caching in remote storage environments, including various cloud storage options, or alternatively, in local storage.

  • I find if you're aware about how you define your modules, incremental compiles are usually pretty quick. Yes a complete build can take a while but tools like sccache[0] can help with that in CI pipelines and when getting a new dev environment up.

    [0]: https://github.com/mozilla/sccache

  • cargo-expand

    Subcommand to show result of macro expansion

  • Ignore the first line, it's how the macro vec! expands. The second line shows the difference in what the versions generate. The first takes a borrow of the result of parse, the second takes a Cow::Owned of it. (Cow stands for copy on write, but it's more generally useful for anything where you want to be generic over either the borrowed or owned version of something.).

    So the short answer is the macro used to expand to something that wasn't owned, and not it does. As for why it worked without a separate assignment, that's because Rust automatically created a temporary variable for you.

    > When using a value expression in most place expression contexts, a temporary unnamed memory location is created initialized to that value and the expression evaluates to that location instead, except if promoted to a static

    https://doc.rust-lang.org/reference/expressions.html#tempora...

    I took a look at the git blame[2] for the element! macro in lol_html, and they made the change because someone opened an issue with essentially your problem. So I'd say this is a bug in a leaky abstraction, not an issue with your understanding of rust.

    [1]: https://github.com/dtolnay/cargo-expand

  • lol-html

    Low output latency streaming HTML parser/rewriter with CSS selector-based API

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts