Skip to content

Commit

Permalink
add lifetime bound to the thread
Browse files Browse the repository at this point in the history
  • Loading branch information
bjcscat committed Dec 8, 2024
1 parent 2915ad2 commit 373e4d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/threads.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::{cell::Cell, error::Error, fmt::Display, rc::Rc};
use std::{cell::Cell, error::Error, fmt::Display, marker::PhantomData, rc::Rc};

use crate::{Luau, _LuaState};

pub struct LuauThread {
pub struct LuauThread<'lua> {
root_check: Rc<Cell<bool>>,
thread: *mut Luau,
_marker: PhantomData<&'lua Luau>
}

#[derive(Debug)]
Expand All @@ -21,13 +22,14 @@ impl Display for MainStateDeadError {
}
}

impl LuauThread {
impl LuauThread<'_> {
pub unsafe fn from_ptr(state: *mut _LuaState, root_check: Rc<Cell<bool>>) -> Self {
let boxed_luau = Box::new(Luau::from_ptr(state));

Self {
root_check,
thread: Box::into_raw(boxed_luau)
thread: Box::into_raw(boxed_luau),
_marker: PhantomData {}
}
}

Expand Down

0 comments on commit 373e4d0

Please sign in to comment.