From 82c8b902e09a21a9befa4e037beadefbe2360b7f Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 12 Apr 2024 21:36:47 +0530 Subject: [PATCH] fix: exit codes are of `u8`, not `i32` --- lib/exit.rs | 6 +++--- lib/functions.rs | 2 +- lib/scheduler.rs | 4 ++-- lib/traits.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/exit.rs b/lib/exit.rs index bc29d78..d8d9bd3 100644 --- a/lib/exit.rs +++ b/lib/exit.rs @@ -4,7 +4,7 @@ use event_listener::Event; #[derive(Debug, Clone)] pub(crate) struct Exit { - code: Rc>>, + code: Rc>>, event: Rc, } @@ -16,12 +16,12 @@ impl Exit { } } - pub fn set(&self, code: i32) { + pub fn set(&self, code: u8) { self.code.set(Some(code)); self.event.notify(usize::MAX); } - pub fn get(&self) -> Option { + pub fn get(&self) -> Option { self.code.get() } diff --git a/lib/functions.rs b/lib/functions.rs index 801d989..06e5c25 100644 --- a/lib/functions.rs +++ b/lib/functions.rs @@ -230,7 +230,7 @@ impl<'lua> Functions<'lua> { let exit_env = lua.create_table_from(vec![ ( "exit", - lua.create_function(|lua, code: Option| { + lua.create_function(|lua, code: Option| { let _span = tracing::trace_span!("Scheduler::fn_exit").entered(); let code = code.unwrap_or_default(); lua.set_exit_code(code); diff --git a/lib/scheduler.rs b/lib/scheduler.rs index 05300c9..9a43aa3 100644 --- a/lib/scheduler.rs +++ b/lib/scheduler.rs @@ -167,7 +167,7 @@ impl<'lua> Scheduler<'lua> { Gets the exit code for this scheduler, if one has been set. */ #[must_use] - pub fn get_exit_code(&self) -> Option { + pub fn get_exit_code(&self) -> Option { self.exit.get() } @@ -176,7 +176,7 @@ impl<'lua> Scheduler<'lua> { This will cause [`Scheduler::run`] to exit immediately. */ - pub fn set_exit_code(&self, code: i32) { + pub fn set_exit_code(&self, code: u8) { self.exit.set(code); } diff --git a/lib/traits.rs b/lib/traits.rs index 1a240d2..4ecac37 100644 --- a/lib/traits.rs +++ b/lib/traits.rs @@ -80,7 +80,7 @@ pub trait LuaSchedulerExt<'lua> { Panics if called outside of a running [`Scheduler`]. */ - fn set_exit_code(&self, code: i32); + fn set_exit_code(&self, code: u8); /** Pushes (spawns) a lua thread to the **front** of the current scheduler. @@ -281,7 +281,7 @@ pub trait LuaSpawnExt<'lua> { } impl<'lua> LuaSchedulerExt<'lua> for Lua { - fn set_exit_code(&self, code: i32) { + fn set_exit_code(&self, code: u8) { let exit = self .app_data_ref::() .expect("exit code can only be set from within an active scheduler");