diff --git a/src/chunk.rs b/src/chunk.rs index d54b385..0dc781d 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -134,7 +134,7 @@ pub struct Compiler { #[cfg(any(feature = "luau", doc))] impl Default for Compiler { fn default() -> Self { - Self::new() + const { Self::new() } } } @@ -323,8 +323,8 @@ impl<'a> Chunk<'a> { /// necessary to populate the environment in order for scripts using custom environments to be /// useful. pub fn set_environment(mut self, env: impl IntoLua) -> Self { - let lua = self.lua.lock(); - let lua = lua.lua(); + let guard = self.lua.lock(); + let lua = guard.lua(); self.env = env .into_lua(lua) .and_then(|val| lua.unpack(val)) @@ -357,8 +357,7 @@ impl<'a> Chunk<'a> { /// /// This is equivalent to calling the chunk function with no arguments and no return values. pub fn exec(self) -> Result<()> { - self.call::<()>(())?; - Ok(()) + self.call(()) } /// Asynchronously execute this chunk of code. diff --git a/src/multi.rs b/src/multi.rs index c631ccd..29d2f38 100644 --- a/src/multi.rs +++ b/src/multi.rs @@ -141,7 +141,7 @@ impl Variadic { impl Default for Variadic { fn default() -> Variadic { - Variadic::new() + const { Variadic::new() } } } diff --git a/src/serde/de.rs b/src/serde/de.rs index 0d72d83..c54241a 100644 --- a/src/serde/de.rs +++ b/src/serde/de.rs @@ -51,7 +51,7 @@ pub struct Options { impl Default for Options { fn default() -> Self { - Self::new() + const { Self::new() } } } diff --git a/src/serde/ser.rs b/src/serde/ser.rs index 0267db7..3f20743 100644 --- a/src/serde/ser.rs +++ b/src/serde/ser.rs @@ -52,7 +52,7 @@ pub struct Options { impl Default for Options { fn default() -> Self { - Self::new() + const { Self::new() } } } diff --git a/src/state.rs b/src/state.rs index 3d3c096..c8ba1f5 100644 --- a/src/state.rs +++ b/src/state.rs @@ -104,7 +104,7 @@ pub struct LuaOptions { impl Default for LuaOptions { fn default() -> Self { - LuaOptions::new() + const { LuaOptions::new() } } } @@ -1251,7 +1251,7 @@ impl Lua { /// /// This methods provides a way to add fields or methods to userdata objects of a type `T`. pub fn register_userdata_type(&self, f: impl FnOnce(&mut UserDataRegistry)) -> Result<()> { - let mut registry = UserDataRegistry::new(); + let mut registry = const { UserDataRegistry::new() }; f(&mut registry); let lua = self.lock(); diff --git a/src/state/raw.rs b/src/state/raw.rs index d489576..c10ccc8 100644 --- a/src/state/raw.rs +++ b/src/state/raw.rs @@ -723,7 +723,7 @@ impl RawLua { } // Create a new metatable from `UserData` definition - let mut registry = UserDataRegistry::new(); + let mut registry = const { UserDataRegistry::new() }; T::register(&mut registry); self.register_userdata_metatable(registry) @@ -742,7 +742,7 @@ impl RawLua { } // Create an empty metatable - let registry = UserDataRegistry::new(); + let registry = const { UserDataRegistry::new() }; self.register_userdata_metatable::(registry) }) }