From 550223a1d783f7e9f833eb7018c5e648ca164f20 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Sat, 21 Feb 2026 22:14:45 +0800 Subject: [PATCH] refactor: tidy --- nix-js/src/codegen.rs | 2 +- nix-js/src/context.rs | 16 ++++++---------- nix-js/src/runtime.rs | 2 +- nix-js/src/runtime/ops.rs | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/nix-js/src/codegen.rs b/nix-js/src/codegen.rs index 015d6c0..196271c 100644 --- a/nix-js/src/codegen.rs +++ b/nix-js/src/codegen.rs @@ -57,7 +57,7 @@ pub(crate) fn compile_scoped(expr: &Ir, ctx: &impl CodegenContext) -> String { buf.into_string() } -pub(crate) struct CodeBuffer { +struct CodeBuffer { buf: String, } diff --git a/nix-js/src/context.rs b/nix-js/src/context.rs index 086775b..a4f56d6 100644 --- a/nix-js/src/context.rs +++ b/nix-js/src/context.rs @@ -182,7 +182,7 @@ impl Context { } } -pub(crate) struct Ctx { +struct Ctx { symbols: DefaultStringInterner, global: HashMap>, sources: Vec, @@ -307,7 +307,7 @@ impl Ctx { ) } - pub(crate) fn get_current_dir(&self) -> &Path { + fn get_current_dir(&self) -> &Path { self.sources .last() .as_ref() @@ -315,17 +315,13 @@ impl Ctx { .get_dir() } - pub(crate) fn get_current_source(&self) -> Source { + fn get_current_source(&self) -> Source { self.sources .last() .expect("current_source is not set") .clone() } - pub(crate) fn get_source(&self, id: usize) -> Source { - self.sources.get(id).expect("source not found").clone() - } - fn downgrade<'ctx>( &'ctx mut self, source: Source, @@ -363,7 +359,7 @@ impl Ctx { Ok(code) } - pub(crate) fn compile_scoped(&mut self, source: Source, scope: Vec) -> Result { + fn compile_scoped(&mut self, source: Source, scope: Vec) -> Result { let scope = Scope::ScopedImport( scope .into_iter() @@ -419,7 +415,7 @@ impl RuntimeContext for Ctx { self.compile_scoped(source, scope) } fn get_source(&self, id: usize) -> Source { - self.get_source(id) + self.sources.get(id).expect("source not found").clone() } fn get_store(&self) -> &DaemonStore { &self.store @@ -454,7 +450,7 @@ impl<'ir, 'ctx> ScopeGuard<'_, 'ctx, 'ir> { } } -pub struct DowngradeCtx<'ctx, 'ir> { +struct DowngradeCtx<'ctx, 'ir> { bump: &'ir Bump, symbols: &'ctx mut DefaultStringInterner, source: Source, diff --git a/nix-js/src/runtime.rs b/nix-js/src/runtime.rs index 0c28d29..ab0e4e5 100644 --- a/nix-js/src/runtime.rs +++ b/nix-js/src/runtime.rs @@ -91,7 +91,7 @@ fn runtime_extension() -> Extension { mod private { use deno_error::js_error_wrapper; #[derive(Debug)] - pub struct SimpleErrorWrapper(pub(crate) String); + pub struct SimpleErrorWrapper(String); impl std::fmt::Display for SimpleErrorWrapper { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.0, f) diff --git a/nix-js/src/runtime/ops.rs b/nix-js/src/runtime/ops.rs index 59849b3..aa5de89 100644 --- a/nix-js/src/runtime/ops.rs +++ b/nix-js/src/runtime/ops.rs @@ -60,7 +60,7 @@ where #[derive(Embed)] #[folder = "src/runtime/corepkgs"] -pub(crate) struct CorePkgs; +struct CorePkgs; fn new_simple_jserror(msg: String) -> Box { JsError {