diff options
author | kyren <kerriganw@gmail.com> | 2018-09-04 17:36:06 -0400 |
---|---|---|
committer | kyren <kerriganw@gmail.com> | 2018-09-04 17:36:06 -0400 |
commit | 30a94c4decf225f8e48d36ed13deb25562a0cb1f (patch) | |
tree | 695e4272a5df95215a1e4f78839e49f38a697c77 /src/lua.rs | |
parent | bd00af2bac54633103e05fe96bbc055897f507c0 (diff) | |
download | mlua-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.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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>, |