On Error Handling in Rust
This is a sugar-coated version of errors as return values. It fixes the most glaring problem, which is code that does not check for errors, common in C:<p><pre><code>     FILE* f = fopen("somefile", "r");
     fwrite("aha", 4, 1, f); // <-- Unchecked use of f here
</code></pre>
In Rust (pardon my rust, I'm totally ignorant), it'd be:<p><pre><code>    let f = fopen("somefile", "r");
    fwrite("aha", f)?;
</code></pre>
The compiler would know that fopen may return an error, and forbid me from running unchecked code. Nice!<p>I'd miss, however, the ability to handle all errors occurring from a segment of code in the same place, stuff that exceptions allow for. Pythonish example<p><pre><code>    try: 
        db = pgsql.connect(localhost)
        stmt = db.prepare('INSERT INTO log VALUES(?,?)')
        stmt.execute(('debug', 'Note to self: debug logs are noncritical'))
    except Exception,e:
        console.write('Could not write log to database %s' % (str(e)))
</code></pre>
Sometimes error recovery is the same for all of the segment. I realize one could extract a function for the commonly recovered code, but this may lead to a too-many-small-functions-with-one-caller(tm) smell.<p>Exceptions aren't the only way to achieve this. If Rust wants to keep return values as the error mechanism, perhaps it could find a way of allowing recovery to happen in the same place for a segment of code.