pub fn pin_init_scope<T, E, F, I>(make_init: F) -> impl PinInit<T, E>Expand description
Construct an initializer in a closure and run it.
Returns an initializer that first runs the closure and then the initializer returned by it.
See also init_scope.
ยงExamples
fn init_foo() -> impl PinInit<Foo, Error> {
pin_init_scope(|| {
let bar = lookup_bar()?;
Ok(try_pin_init!(Foo { a: bar.a.into(), b: bar.b }? Error))
})
}This initializer will first execute lookup_bar(), match on it, if it returned an error, the
initializer itself will fail with that error. If it returned Ok, then it will run the
initializer returned by the try_pin_init! invocation.