5 ms·
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 i
by umanwizard 5y ago
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.
- tialaramex 5y agoYou 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.
- umanwizard 5y ago> You can't push_str() under cfg(no_global_oom_handling) either Thanks for the clarification. I had totally missed the point.