pub(crate) fn with<F, T>(c: F) -> Result<T, VmError>
where
    F: FnOnce(&Arc<RuntimeContext>, &Arc<Unit>) -> Result<T, VmError>,
{
    let env = ENV.with(|env| env.get());
    let Env { context, unit } = env;

    if context.is_null() || unit.is_null() {
        return Err(VmError::from(VmErrorKind::MissingInterfaceEnvironment));
    }

    // Safety: context and unit can only be registered publicly through
    // [Guard], which makes sure that they are live for the duration of
    // the registration.
    c(unsafe { &*context }, unsafe { &*unit })
}
/// Call the given closure with access to the checked environment.
Call the given closure with access to the checked environment.
Call the given closure with access to the checked environment .
pub(crate) fn with<F, T>(c: F) -> Result<T, VmError>
where
    F: FnOnce(&Arc<RuntimeContext>, &Arc<Unit>) -> Result<T, VmError>,
{
    let env = ENV.with(|env| env.get());
    let Env { context, unit } = env;
    if context.is_null() || unit.is_null() {
        return Err(VmError::from(VmErrorKind::MissingInterfaceEnvironment));
    }
    // Safety: context and unit can only be registered publicly through
    // [Guard], which makes sure that they are live for the duration of
    // the registration.
    c(unsafe { &*context }, unsafe { &*unit })
}
pub ( crate ) fn with < F , T > ( c : F ) -> Result < T , VmError > where F : FnOnce ( & Arc < RuntimeContext > , & Arc < Unit > ) -> Result < T , VmError > , { let env = ENV . with ( | env | env . get ( ) ) ; let Env { context , unit } = env ; if context . is_null ( ) || unit . is_null ( ) { return Err ( VmError :: from ( VmErrorKind :: MissingInterfaceEnvironment ) ) ; } // Safety: context and unit can only be registered publicly through // [Guard], which makes sure that they are live for the duration of // the registration. c ( unsafe { & * context } , unsafe { & * unit } ) }
Call the given closure with access to the checked environment.
Call the given closure with access to the checked environment .
c
F
c
F