What Is in a Rust Allocator?

sulami | 94 points

I have never investigated why, but each time I look at this API it strikes me that the allocator isn't allowed to tell you how much space it actually gave you.

Suppose I'm an allocator which only has power-of-2 sized spaces to hand out, and you're a growable array type and you want enough space for 20 of your 52 byte entries. So that's 20x52 = 1040 bytes, but my smallest suitable space is 2048 bytes. I can give you that space, but it seems like it'd be nice for me to say oh, here's 2048 bytes, and now the growable array type knows its new total capacity is not 20 but 39.

tialaramex | 13 days ago