1. 57
    1. 11

      This is a helpful article for me, thank you for posting!

      Does Lobsters allow posts like these, though? It’s a great article, but includes an ad for a service as the last section.

      1. 9

        It’s a useful article until then so it’s worth letting the votes govern its relevance, imo.

      2. 6

        I’d say there’s a difference between “here’s some useful Rust stuff, btw use our logging SaaS at the end” and “here’s why you should use our logging SaaS”

      3. 5

        Author here, glad you like it.

        I will add a conclusive sentence to make the distinction between the article and the advertisement clearer.

        1. 1

          Thanks for the article, I didn’t mind the ad. Do you inspect the stack frames non-intrusively via sampling?

      4. 4

        if it’s not too intrusive its okay, for example when you can read the article without the ad and you don’t miss big parts of the post

      5. 3

        Personally, I don’t mind it. There’s a lot of great and interesting content out there published by companies that usually includes some sort of “ad” for their service. I don’t want to cut that out just because they say, “hey, use our stuff” at the end. Especially because I can just ignore the ad bit and still learn something.

    2. 5

      Thanks for sharing, here! I like this approach to trying to learn Rust, because there are a handful of patterns in other languages that aren’t feasible in Rust

      1. 2

        Glad you like it. And yes, Rust chooses some tradeoffs differently than other languages, which sometimes trips up people new to the language.

    3. 8

      Knowing these impossible cases is quite useful — it can save you from fighting with the borrow checker a battle that you can’t win.

      1. 5

        Well, not exactly impossible, just needs a bit of unsafe and – Oh god why are there dolphins swimming in my pretzel bath (undefined behavior)?

    4. 4

      Also, as far as I know: If another package exposes enums, you can’t choose a random one of those without modifying the original package.

    5. 2

      Hmm, helpful, but perhaps not as helpful as it could be.

      • “Linked lists” could be better described as “cyclic data structures”. For most graph algorithms I’ve seen the adjacency-list representation is more convenient anyway, so I tend to find graphs represented as nodes and pointers to be something of a white elephant. I’m far from an expert though.
      • Self-referencing data structures are now possible with Pin, though reading the docs there still are probably enough to convince anyone that they don’t want want a self-referential data structure after all.
      • The main reason not to have global mutable state, besides the sanity of the person who has to read the code later, is thread safety. They talk about mutexes and such but never say “global mutable state becomes unsafe once you have threads”.

      All in all a good post though. As for initializing an array without re-initializing it, I had to give it a go and see what happened. The results were, hilariously at once more and less than I could hope.

      1. 3
        • True, the problem with doubly linked lists (as well as other cyclic data structures) is indeed the ownership being muddled.
        • Yes, you can build self-referential data using pin, but why do it by hand when you can use a macro?
        • Regarding global mutable state, I have a // I solemny swear that I'm up to no good, and also single threaded. comment in the code example, but perhaps that was too easy to miss.