pub fn with_resources<'lua, R>(
        &mut self,
        lua: &'lua Lua,
        resources: &Resources,
        f: impl FnOnce(LuaTable<'lua>) -> R,
    ) -> Result<R> {
        let env = lua.registry_value(&self.env)?;
        let mut erased_loanables = Vec::with_capacity_in(self.map.len(), &self.bump_arena);
        for resource in self.map.values() {
            if let Err(error) = (resource.loanable)(
                lua,
                &env,
                resources,
                &self.bump_arena,
                &mut erased_loanables,
            ) {
                tracing::error!(
                    name = %resource.name,
                    ?error,
                    "failed to borrow resource {}: {:?}",
                    resource.name,
                    error,
                );
            }
        }

        let out = self.scope_arena.scope(|guard| {
            for loanable in &mut erased_loanables {
                loanable.erased_loan(guard, &self.map, lua)?;
            }

            Ok(f(env))
        });

        drop(erased_loanables);

        self.bump_arena.reset();
        self.scope_arena.reset();

        out
    }
/// Borrow all of the registered resources in this context from the given [`Resources`], and
/// then call the given thunk, passing in the registry key corresponding to this script
/// context's environment table (if it exists.)
///
/// Loans will be valid until the thunk returns.
Borrow all of the registered resources in this context from the given [`Resources`], and
then call the given thunk, passing in the registry key corresponding to this script
context's environment table (if it exists.)

Loans will be valid until the thunk returns.
Borrow all of the registered resources in this context from the given [ ` Resources ` ] and then call the given thunk passing in the registry key corresponding to this script context ' s environment table ( if it exists . ) Loans will be valid until the thunk returns .
pub fn with_resources<'lua, R>(
        &mut self,
        lua: &'lua Lua,
        resources: &Resources,
        f: impl FnOnce(LuaTable<'lua>) -> R,
    ) -> Result<R> {
        let env = lua.registry_value(&self.env)?;
        let mut erased_loanables = Vec::with_capacity_in(self.map.len(), &self.bump_arena);
        for resource in self.map.values() {
            if let Err(error) = (resource.loanable)(
                lua,
                &env,
                resources,
                &self.bump_arena,
                &mut erased_loanables,
            ) {
                tracing::error!(
                    name = %resource.name,
                    ?error,
                    "failed to borrow resource {}: {:?}",
                    resource.name,
                    error,
                );
            }
        }
        let out = self.scope_arena.scope(|guard| {
            for loanable in &mut erased_loanables {
                loanable.erased_loan(guard, &self.map, lua)?;
            }
            Ok(f(env))
        });
        drop(erased_loanables);
        self.bump_arena.reset();
        self.scope_arena.reset();
        out
    }
pub fn with_resources < ' lua , R > ( & mut self , lua : & ' lua Lua , resources : & Resources , f : impl FnOnce ( LuaTable < ' lua > ) -> R , ) -> Result < R > { let env = lua . registry_value ( & self . env ) ? ; let mut erased_loanables = Vec :: with_capacity_in ( self . map . len ( ) , & self . bump_arena ) ; for resource in self . map . values ( ) { if let Err ( error ) = ( resource . loanable ) ( lua , & env , resources , & self . bump_arena , & mut erased_loanables , ) { tracing :: error ! ( name resource name error " " resource name error ) ; } } let out = self . scope_arena . scope ( | guard | { for loanable in & mut erased_loanables { loanable . erased_loan ( guard , & self . map , lua ) ? ; } Ok ( f ( env ) ) } ) ; drop ( erased_loanables ) ; self . bump_arena . reset ( ) ; self . scope_arena . reset ( ) ; out }
Borrow all of the registered resources in this context from the given [`Resources`], and
then call the given thunk, passing in the registry key corresponding to this script
context's environment table (if it exists.)
Borrow all of the registered resources in this context from the given [ ` Resources ` ] and then call the given thunk passing in the registry key corresponding to this script context ' s environment table ( if it exists . )
&mut self
lua
&'lua Lua
resources
&Resources
f
impl FnOnce(LuaTable<'lua>) -> R
&mut self
lua
&'lua Lua
resources
&Resources
f
impl FnOnce(LuaTable<'lua>) -> R