From 44b6eecd70a2eeed62b18365c1b0252ca7c70729 Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Sun, 25 Feb 2018 22:49:18 -0600 Subject: [PATCH] make it possible to execute an lua file and code block in the same module --- src/modules/lua.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/modules/lua.rs b/src/modules/lua.rs index 9766128..03eea2e 100644 --- a/src/modules/lua.rs +++ b/src/modules/lua.rs @@ -125,14 +125,12 @@ impl EventLoop for LuaModule { sender: Box::new(sender.clone()) }); - match self.code { - Some(ref code) => { lua.execute(&code).unwrap() }, - None => { - match self.file { - Some(ref file) => { lua.execute_from_reader::<(), _>(File::open(&Path::new(file)).unwrap()).unwrap(); } - None => {} - } - } + if let Some(ref file) = self.file { + lua.execute_from_reader::<(), _>(File::open(&Path::new(file)).unwrap()).unwrap(); + } + + if let Some(ref code) = self.code { + lua.execute(&code).unwrap() } loop {