News for hackers. Stuff that matters.
Re:Dealing with Out-of-Memory Conditions in Rust by umanwizard on Sunday August 15, 2021 @12:10AM (#28186196)
I’ve been doing Rust full-time for two years and I had no idea you could do this. I’d just have used `push_str` in any case.

Giving this up doesn’t seem very impactful and I’d be happy to do so to enable actually useful features.

Re:Dealing with Out-of-Memory Conditions in Rust by tialaramex on Sunday August 15, 2021 @09:42AM (#28188690)
You can't push_str() under cfg(no_global_oom_handling) either

I mean, they did warn you: No Global OOM Handling. So, if this mustn't fail, and it might not succeed, therefore it has to be eliminated, a String under cfg(no_global_oom_handling) can't push_str() and it can't reserve() and it can't do a lot of things. Their definitions are conditionally removed from the type.

I didn't check, it's possible "something".to_owned() is similarly forbidden, seems like that would allocate memory.

Basically if you live in a world where allocating memory for strings, vectors, and other growable types feels extravagant, cfg(no_global_oom_handling) is for you, and if not then maybe you should re-evaluate why you are worried about allocation failures when you are wasting precious heap memory on such data structures.

Re:Dealing with Out-of-Memory Conditions in Rust by umanwizard on Sunday August 15, 2021 @08:43PM (#28193869)
> You can't push_str() under cfg(no_global_oom_handling) either

Thanks for the clarification. I had totally missed the point.