Update `create_registry_value` doc

This commit is contained in:
Alex Orlenko 2022-02-15 19:45:37 +00:00
parent 18c3255c90
commit 10826a7e67
No known key found for this signature in database
GPG Key ID: 4C150C250863B96D
1 changed files with 3 additions and 2 deletions

View File

@ -1708,11 +1708,12 @@ impl Lua {
/// Place a value in the Lua registry with an auto-generated key. /// Place a value in the Lua registry with an auto-generated key.
/// ///
/// This value will be available to rust from all `Lua` instances which share the same main /// This value will be available to Rust from all `Lua` instances which share the same main
/// state. /// state.
/// ///
/// Be warned, garbage collection of values held inside the registry is not automatic, see /// Be warned, garbage collection of values held inside the registry is not automatic, see
/// [`RegistryKey`] for more details. /// [`RegistryKey`] for more details.
/// However, dropped [`RegistryKey`]s automatically reused to store new values.
/// ///
/// [`RegistryKey`]: crate::RegistryKey /// [`RegistryKey`]: crate::RegistryKey
pub fn create_registry_value<'lua, T: ToLua<'lua>>(&'lua self, t: T) -> Result<RegistryKey> { pub fn create_registry_value<'lua, T: ToLua<'lua>>(&'lua self, t: T) -> Result<RegistryKey> {
@ -1809,7 +1810,7 @@ impl Lua {
let t = t.to_lua(self)?; let t = t.to_lua(self)?;
unsafe { unsafe {
let _sg = StackGuard::new(self.state); let _sg = StackGuard::new(self.state);
check_stack(self.state, 4)?; check_stack(self.state, 2)?;
self.push_value(t)?; self.push_value(t)?;
// It must be safe to replace the value without triggering memory error // It must be safe to replace the value without triggering memory error