It would be inlined by the compiler, and the standard library could introduce a macro to eliminate the awkward code.
try!({
let db = pgsql.connect(localhost)?
let stmt = db.prepare("INSERT INTO log VALUES(?,?)")?
stmt.execute(("debug", "Note to self: debug logs are noncritical"))?
} catch err: DatabaseError {
println!("Could not write log to database {}", err);
})
===>
match (|| {
let db = pgsql.connect(localhost)?
let stmt = db.prepare("INSERT INTO log VALUES(?,?)")?
stmt.execute(("debug", "Note to self: debug logs are noncritical"))?
}) {
Document(d) => d,
DatabaseError(err) => println!("Could not write log to database {}", err)
}
Closures aren't "free", you need to structure your code around being unable to return/break/continue across the closure boundary, and there's probably some silly borrow checker errors involved too.