3 ms·
Can someone expand on the debate about alloc()? Does Rust always panic on allocation failure?
by secondcoming 6y ago
Can someone expand on the debate about alloc()?
Does Rust always panic on allocation failure?
- steveklabnik 6y ago> Does Rust always panic on allocation failure? No. See more below. > Can someone expand on the debate about alloc()? So the question is the one you asked above, but also, more generally, "is it possible to statically disallow panic on OOM?" and related things. Rust the language itself, that is, the language + the core library, doesn't know anything about allocations at all. There are none. Concept doesn't exist. So that's fine. Rust also provides the "alloc" library, which can be layered on top of core. This gives you standard APIs for allocation. They also contain several data structures that use allocation internally. These data structures have APIs that may panic on OOM. So, Linus saw those things, and naturally asked questions about how required they are. The answer is "not required, but it's work to get rid of them, there's a few options, and we didn't want to do that work until we got a higher-level gut check from you." Does that all make sense?
- secondcoming 6y agoSure does. Thanks!
- asimpletune 6y agoGreat explanation, thanks
- Gadiguibou 6y agoThank you for taking the time to explain this. I'm familiar with Rust, but didn't know what he was referring to.