From 97de75252d7cdf9a3bec12135df368cc231c824d Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Tue, 23 Jun 2026 18:33:05 +0200 Subject: [PATCH] Updated api bootstrap --- crates/mist-api/src/builder.mist | 8 ++++---- crates/mist-api/src/modules.mist | 4 ++-- crates/mist-api/src/transpiler.mist | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/mist-api/src/builder.mist b/crates/mist-api/src/builder.mist index 27aa308..6571786 100644 --- a/crates/mist-api/src/builder.mist +++ b/crates/mist-api/src/builder.mist @@ -57,7 +57,7 @@ pub bool build(Vec mut args, PathBuf root) { break; } - let map = mapping.entry(mapping_path.clone()).or_insert_with(fn() { + let map = mapping.entry(mapping_path.clone()).or_insert_with(() => { let map_str = fs::read_to_string(mapping_path).expect("Failed to read map file"); serde_json::from_str(&map_str).expect("Failed to parse map file") @@ -107,7 +107,7 @@ pub bool build(Vec mut args, PathBuf root) { let mut stdout = std::io::stdout(); std::io::copy(&mut raw_reader, &mut stdout) - .map_err(fn(v) -> v.to_string()) + .map_err((v) => v.to_string()) .expect("(Mist) Failed to copy IO"); command.wait().unwrap(); @@ -165,7 +165,7 @@ pub Option get_line( ) { let src_path = msg.file_path.clone(); - let lines = files.entry(src_path.clone()).or_insert_with(fn() { + let lines = files.entry(src_path.clone()).or_insert_with(() => { fs::read_to_string(src_path) .expect("Unable to read mist file") .lines() @@ -174,5 +174,5 @@ pub Option get_line( .collect() }); - lines.get(msg.line - 1).map(fn(v) -> v.trim().to_string()) + lines.get(msg.line - 1).map((v) => v.trim().to_string()) } diff --git a/crates/mist-api/src/modules.mist b/crates/mist-api/src/modules.mist index 4b5dc80..af7b8b3 100644 --- a/crates/mist-api/src/modules.mist +++ b/crates/mist-api/src/modules.mist @@ -16,7 +16,7 @@ pub class Module { pub constructor(PathBuf mist_path, MistConfig& config) { self.children = Vec::new(); self.name = mist_path.file_stem() - .and_then(fn(s) -> s.to_str()) + .and_then((s) => s.to_str()) .expect("Failed to get module name") .to_string(); self.path = mist_path; @@ -66,7 +66,7 @@ pub class Module { } pub bool is_package(&self) { - self.path.file_name().map(fn(v) -> v.to_str()).unwrap_or_default() == Some("package.mist") + self.path.file_name().map((v) => v.to_str()).unwrap_or_default() == Some("package.mist") } pub PathBuf output_dir(&self, PathBuf& parent_dir) { diff --git a/crates/mist-api/src/transpiler.mist b/crates/mist-api/src/transpiler.mist index 406284e..5b6ce8d 100644 --- a/crates/mist-api/src/transpiler.mist +++ b/crates/mist-api/src/transpiler.mist @@ -56,10 +56,10 @@ pub PathBuf transpile() { let out = root.join(".mist/src"); let toml_content = fs::read_to_string(&toml_path) - .unwrap_or_else(fn(_) -> panic!("Could not read file at {:?}", toml_path)); + .unwrap_or_else((_) => panic!("Could not read file at {:?}", toml_path)); MistConfig mut config = toml::from_str(&toml_content) - .unwrap_or_else(fn(_) -> panic!("Failed to parse Mist.toml from {:?}", toml_path)); + .unwrap_or_else((_) => panic!("Failed to parse Mist.toml from {:?}", toml_path)); for pkg in &mut config.packages { *pkg = src.join(&*pkg); @@ -86,9 +86,9 @@ pub PathBuf transpile() { impl modules::Module { (bool, String) transpile(&self, PathBuf& parent_dir, MistConfig mut& config) { - if !self.path.is_dir() && self.path.extension().and_then(fn(v) -> v.to_str()) != Some("mist") { + if !self.path.is_dir() && self.path.extension().and_then((v) => v.to_str()) != Some("mist") { let file_name = self.path.file_name() - .and_then(fn(s) -> s.to_str()) + .and_then((s) => s.to_str()) .expect("Failed to get file name"); fs::copy(&self.path, parent_dir.join(&file_name)).expect("Failed to copy SideFile"); @@ -200,8 +200,8 @@ pub Result<(PathBuf, mist_codegen::RustCodegen, String), TranspileError<'a>> ) { if let Some((_, name)) = &curr_mod_decl { - if output_file.file_name().map(fn(v) -> v.to_str()).unwrap_or_default() != Some("mod.rs") { - if let Some(ext) = output_file.extension().map(fn(e) -> e.to_owned()) { + if output_file.file_name().map((v) => v.to_str()).unwrap_or_default() != Some("mod.rs") { + if let Some(ext) = output_file.extension().map((e) => e.to_owned()) { let mut new_name = std::ffi::OsString::from(&name.0); new_name.push(".");