Skip to content

Commit 1cb081d

Browse files
committed
Do not propagate collect_garbage flag when clonning Lua
1 parent c1a018a commit 1cb081d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/state.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub use raw::RawLua;
4949
use util::{callback_error_ext, StateGuard};
5050

5151
/// Top level Lua struct which represents an instance of Lua VM.
52-
#[derive(Clone)]
5352
pub struct Lua {
5453
pub(self) raw: XRc<ReentrantMutex<RawLua>>,
5554
// Controls whether garbage collection should be run on drop
@@ -151,6 +150,16 @@ impl Drop for Lua {
151150
}
152151
}
153152

153+
impl Clone for Lua {
154+
#[inline]
155+
fn clone(&self) -> Self {
156+
Lua {
157+
raw: XRc::clone(&self.raw),
158+
collect_garbage: false,
159+
}
160+
}
161+
}
162+
154163
impl fmt::Debug for Lua {
155164
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
156165
write!(f, "Lua({:p})", self.lock().state())

0 commit comments

Comments
 (0)