Skip to content

Commit

Permalink
Revert some unnecessary stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Oct 16, 2024
1 parent df4fb9b commit 93fa14d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
7 changes: 2 additions & 5 deletions crates/lune-roblox/src/instance/terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(methods: &mut M)
}

fn get_or_create_material_colors(instance: &Instance) -> MaterialColors {
if let Variant::MaterialColors(inner) = instance
.get_property("MaterialColors")
.unwrap_or(Variant::MaterialColors(MaterialColors::default()))
{
if let Some(Variant::MaterialColors(inner)) = instance.get_property("MaterialColors") {
inner
} else {
unreachable!()
MaterialColors::default()
}
}

Expand Down
11 changes: 7 additions & 4 deletions crates/lune/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use tokio::{
io::{stdin, AsyncReadExt as _},
};

use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};
use lune::Runtime;

use super::utils::files::{discover_script_path_including_lune_dirs, strip_shebang};

/// Run a script
#[derive(Debug, Clone, Parser)]
pub struct RunCommand {
Expand Down Expand Up @@ -39,11 +40,13 @@ impl RunCommand {
(file_display_name, file_contents)
};

// Create a new lune object with all globals & run the script
let mut runtime = Runtime::new().with_args(self.script_args);
let result = runtime
// Create a new lune runtime with all globals & run the script
let mut rt = Runtime::new().with_args(self.script_args);

let result = rt
.run(&script_display_name, strip_shebang(script_contents))
.await;

Ok(match result {
Err(err) => {
eprintln!("{err}");
Expand Down
8 changes: 3 additions & 5 deletions crates/lune/src/rt/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ impl Runtime {
script_name: impl AsRef<str>,
script_contents: impl AsRef<[u8]>,
) -> RuntimeResult<(u8, Vec<LuaValue>)> {
// Create a new scheduler for this run
let lua = self.inner.lua();
let sched = self.inner.scheduler();

Expand All @@ -165,17 +164,16 @@ impl Runtime {
let main_thread_id = sched.push_thread_back(main, ())?;
sched.run().await;

let thread_res = match sched.get_thread_result(main_thread_id) {
let main_thread_res = match sched.get_thread_result(main_thread_id) {
Some(res) => res,
None => LuaValue::Nil.into_lua_multi(lua),
}?
.into_vec();
}?;

Ok((
sched
.get_exit_code()
.unwrap_or(u8::from(got_any_error.load(Ordering::SeqCst))),
thread_res,
main_thread_res.into_vec(),
))
}
}
1 change: 1 addition & 0 deletions crates/lune/src/standalone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub async fn run(patched_bin: impl AsRef<[u8]>) -> Result<ExitCode> {
let meta = Metadata::from_bytes(patched_bin).expect("must be a standalone binary");

let mut rt = Runtime::new().with_args(args);

let result = rt.run("STANDALONE", meta.bytecode).await;

Ok(match result {
Expand Down
4 changes: 0 additions & 4 deletions crates/mlua-luau-scheduler/src/functions.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#![allow(unused_imports)]
#![allow(clippy::too_many_lines)]

use std::process::{ExitCode, ExitStatus};

use mlua::prelude::*;

use crate::{
error_callback::ThreadErrorCallback,
queue::{DeferredThreadQueue, SpawnedThreadQueue},
result_map::ThreadResultMap,
scheduler::Scheduler,
thread_id::ThreadId,
traits::LuaSchedulerExt,
util::{is_poll_pending, LuaThreadOrFunction, ThreadResult},
Expand Down

0 comments on commit 93fa14d

Please sign in to comment.