Explicit allocation Rust / passing allocator to functions / returning options

Matklad recently published an excellent and thought provoking piece at Zig And Rust

As someone who knows no Zig and has no idea of the full powers of comptime, the feature that stuck out most to me is passing allocators as an argument.

I am curious if there are rust stdlib replacement libraries that do this (especially for the embedded space). I envision, for example, Vec.push would take an extra argument (allocator) and return an Optino<()> indicating success / fail.

What is the current status of explicit-allocator Rust libs ?

(Haven't read the article yet)

There is to some extend. E.g. Vec is now generic over the allocator and has an unstable (nightly-only) API to use a different one than the default global one: Vec in std::vec - Rust
It also has a push_within_capacity to allow you to handle reallocation when you need it.

Have you seen this IRLO thread?

1 Like
  1. Thanks for the IRLO thread.

  2. That thread is from Apr 2021 -- has anything changed in the past 2 years ?

  3. The main points I got from that thread chain were:

3a. How to handle Drop

3b. stdlib does not do it (yet); most libs just follow stdlib

Were there any other crucial points ?

Not that I can think of.

The other one is "people seem not to need/want it very badly".