lol idk #1

Open
Quaternions wants to merge 826 commits from StrafesNET/strafe-project:master into master
3 changed files with 7 additions and 16 deletions
Showing only changes of commit 2ccc5bb17d - Show all commits

View File

@ -1,3 +1,3 @@
mod runner; mod runner;
pub use runner::{Runner,Error}; pub use runner::{run,Error};

View File

@ -2,18 +2,9 @@ pub enum Error{
Lua(mlua::Error), Lua(mlua::Error),
} }
pub struct Runner{ pub fn run(source:String,context:&mut crate::context::Context)->Result<(),Error>{
source:String, let lua=mlua::Lua::new();
} lua.sandbox(true).map_err(Error::Lua)?;
lua.load(source).exec().map_err(Error::Lua)?;
impl Runner{ Ok(())
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(())
}
} }

View File

@ -23,6 +23,6 @@ impl Script{
} }
}; };
// run it lole // run it lole
crate::runner::Runner::new(source).run(context).map_err(Error::Runner) crate::runner::run(source,context).map_err(Error::Runner)
} }
} }