summaryrefslogtreecommitdiff
path: root/src/lua.rs
diff options
context:
space:
mode:
authorkyren <kerriganw@gmail.com>2018-09-04 17:36:06 -0400
committerkyren <kerriganw@gmail.com>2018-09-04 17:36:06 -0400
commit30a94c4decf225f8e48d36ed13deb25562a0cb1f (patch)
tree695e4272a5df95215a1e4f78839e49f38a697c77 /src/lua.rs
parentbd00af2bac54633103e05fe96bbc055897f507c0 (diff)
downloadmlua-30a94c4decf225f8e48d36ed13deb25562a0cb1f.zip
Comment updates that I really hope are correct
Tried to explain the rationale for safety around callbacks in Lua and Scope a bit better, because every time I don't look at this for a while I forget my reasoning. I'm not always so great at using the right terminology, so to whoever reads this, if I got this wrong please tell me.
Diffstat (limited to 'src/lua.rs')
-rw-r--r--src/lua.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lua.rs b/src/lua.rs
index 3d61420..7c945ea 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -823,6 +823,13 @@ impl Lua {
Ok(id)
}
+ // Creates a Function out of a Callback containing a 'static Fn. This is safe ONLY because the
+ // Fn is 'static, otherwise it could capture 'callback arguments improperly. Without ATCs, we
+ // cannot easily deal with the "correct" callback type of:
+ //
+ // Box<for<'lua> Fn(&'lua Lua, MultiValue<'lua>) -> Result<MultiValue<'lua>>)>
+ //
+ // So we instead use an outer lifetime, which without the 'static requirement would be unsafe.
pub(crate) fn create_callback<'lua, 'callback>(
&'lua self,
func: Callback<'callback, 'static>,