News for hackers. Stuff that matters.
Re:Asynchronous IO in Rust by acconsta on Thursday September 17, 2015 @11:11PM (#10237312)
That code sample is really helpful, thanks.

But doesn't that seem kind of redundant? Box and std containers are great as is, except for the one line that aborts on OOM. Would it be possible to use traits to choose OOM behavior at compile time?

To be clear, this isn't just important for embedded. A production database or web server should be able to handle an allocation failure without blowing up the whole process.

And I'm glad there's some talk about a standard allocator trait. I'll look for the relevant issue.

Re:Asynchronous IO in Rust by dbaupp on Friday September 18, 2015 @01:42AM (#10237654)
There could definitely be an alternate method on `Box` that returned Result, but I don't think this is so feasible for containers which allocate in many places and so would require duplicating most of the API, however there may be some tricks that work.

https://github.com/rust-lang/rfcs/issues/538 covers the allocator stuff.

Re:Asynchronous IO in Rust by acconsta on Friday September 18, 2015 @02:13PM (#10241006)
Right, duplicating every method that allocates also isn't very elegant.

But could Box and containers be polymorphic on an OOM handling trait?

Alternatively, one could imagine an OOM-safe container that returns results, and a convenience wrapper class that unwraps them. That might harm efficient code generation though.