Unofficial Hacker News client - receive Push Notifications on replies.

The state of Rust allocators in 2026: stabilised (opens external site)

212 points by fanf2 2 days ago | cetra3.github.io | 87 comments on HN | Vote on HN (opens Hacker News)

View full thread · View on Hacker News

Comment thread (10)

  1. Then you should generally go for `no_alloc`, because std allocates, so no_std + no_alloc leaves you with core + a bunch of crates for no_std data manipulation
    Replies (2)
    1. And then I have to deal with writing tons of code to please the borrow checker myself. At which point I might as well go for a language that doesn't need so much ritual.
      Replies (2)
      1. Why not use an LLM to help with the actual syntax while you only need to worry about the data flow? I've found they're quite good with that.
        Replies (1)
        1. It's not just syntax. Depending on the allocation scheme used it can be very difficult to prove to the borrow checker that it's all safe, or even impossible (the same way some data structures in Rust can only be implemented with `unsafe`).
          Replies (2)
          1. If you stick to single ownership and stack tied or static lifetimes it's not too bad. If you're trying to pass parameters with lifetimes that extend beyond the stack frame and aren't static, then yes, that is painful. Callbacks or async style code in particular is challenging.
          2. Agreed, this is why I don't write kernels or things like that in Rust. The borrow checker will assume that your code is running in a parallel (multicore/multithreaded) capable environment, even if it isn't, and there is no way to explicitly tell the borrow checker to stfu, so you have to do a bunch of hack abstractions (Ref<T>, Rc<T>, ...) just to make it shut up.
      2. ...in what way is this related? Ownership is ownership, it's always a factor. Allocation is different because if you don't want any dynamic allocation, you don't want an allocator in the first place, ownership is an orthogonal concern
    2. Huh, that's a thing? I thought there was just `no_std` and then you can simply leave out `extern crate alloc`.
      Replies (2)
      1. Frankly I'm not sure syntactically, didn't have to touch no-std in a bit, so I assume you're right. I do know that no_alloc is a crate tag people use and it's a readable enough way to phrase it
      2. It's exactly as you describe. No_alloc is just no_std without using alloc crate.