Skip to content

Commit

Permalink
Remove Lua::into_static and Lua::from_static (undocumented).
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Aug 5, 2024
1 parent 8e14b6e commit ac6a391
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 152 deletions.
30 changes: 0 additions & 30 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,36 +344,6 @@ impl Lua {
loaded.raw_set(modname, Nil)
}

/// Consumes and leaks `Lua` object, returning a static reference `&'static Lua`.
///
/// This function is useful when the `Lua` object is supposed to live for the remainder
/// of the program's life.
///
/// Dropping the returned reference will cause a memory leak. If this is not acceptable,
/// the reference should first be wrapped with the [`Lua::from_static`] function producing a
/// `Lua`. This `Lua` object can then be dropped which will properly release the allocated
/// memory.
///
/// [`Lua::from_static`]: #method.from_static
///
/// FIXME: remove
#[doc(hidden)]
pub fn into_static(self) -> &'static Self {
Box::leak(Box::new(self))
}

/// Constructs a `Lua` from a static reference to it.
///
/// # Safety
/// This function is unsafe because improper use may lead to memory problems or undefined
/// behavior.
///
/// FIXME: remove
#[doc(hidden)]
pub unsafe fn from_static(lua: &'static Lua) -> Self {
*Box::from_raw(lua as *const Lua as *mut Lua)
}

// Executes module entrypoint function, which returns only one Value.
// The returned value then pushed onto the stack.
#[doc(hidden)]
Expand Down
122 changes: 0 additions & 122 deletions tests/static.rs

This file was deleted.

0 comments on commit ac6a391

Please sign in to comment.