mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
More inline const expressions
This commit is contained in:
+4
-5
@@ -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.
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ impl<T> Variadic<T> {
|
||||
|
||||
impl<T> Default for Variadic<T> {
|
||||
fn default() -> Variadic<T> {
|
||||
Variadic::new()
|
||||
const { Variadic::new() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ pub struct Options {
|
||||
|
||||
impl Default for Options {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
const { Self::new() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ pub struct Options {
|
||||
|
||||
impl Default for Options {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
const { Self::new() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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<T: 'static>(&self, f: impl FnOnce(&mut UserDataRegistry<T>)) -> Result<()> {
|
||||
let mut registry = UserDataRegistry::new();
|
||||
let mut registry = const { UserDataRegistry::new() };
|
||||
f(&mut registry);
|
||||
|
||||
let lua = self.lock();
|
||||
|
||||
+2
-2
@@ -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::<T>(registry)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user