foundationdb-rs icon indicating copy to clipboard operation
foundationdb-rs copied to clipboard

Safe alternative to "boot"

Open Diggsey opened this issue 3 years ago • 0 comments

The documentation says "boot" is unsafe because it can't guarantee that the return value is dropped. The typical solution to this in Rust is to have the function take a closure.

fn run<R>(f: impl FnOnce() -> R) -> R;

Unfortunately this doesn't work for async functions, since you can't stop the return future being leaked, but you could add an attribute like #[foundationdb::main] that can be combined with eg. #[tokio::main].

Diggsey avatar Sep 12 '21 00:09 Diggsey