From 2ccc5bb17df0c41d5630aeaba16c5d294095336f Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 16 Sep 2024 19:01:16 -0700 Subject: [PATCH] runner: no object --- src/runner/mod.rs | 2 +- src/runner/runner.rs | 19 +++++-------------- src/script.rs | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 5cf589b..e525f415 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -1,3 +1,3 @@ mod runner; -pub use runner::{Runner,Error}; +pub use runner::{run,Error}; diff --git a/src/runner/runner.rs b/src/runner/runner.rs index b8194c2..f670fbf 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -2,18 +2,9 @@ pub enum Error{ Lua(mlua::Error), } -pub struct Runner{ - source:String, -} - -impl Runner{ - pub const fn new(source:String)->Self{ - Self{source} - } - pub fn run(self,context:&mut crate::context::Context)->Result<(),Error>{ - let lua=mlua::Lua::new(); - lua.sandbox(true).map_err(Error::Lua)?; - lua.load(self.source).exec().map_err(Error::Lua)?; - Ok(()) - } +pub fn run(source:String,context:&mut crate::context::Context)->Result<(),Error>{ + let lua=mlua::Lua::new(); + lua.sandbox(true).map_err(Error::Lua)?; + lua.load(source).exec().map_err(Error::Lua)?; + Ok(()) } diff --git a/src/script.rs b/src/script.rs index 3027c7c..b893afd 100644 --- a/src/script.rs +++ b/src/script.rs @@ -23,6 +23,6 @@ impl Script{ } }; // run it lole - crate::runner::Runner::new(source).run(context).map_err(Error::Runner) + crate::runner::run(source,context).map_err(Error::Runner) } }