From dbb38581aa1f5316acedf623dfd92c882c2599b7 Mon Sep 17 00:00:00 2001 From: Sam Estep Date: Tue, 21 Jan 2025 09:27:17 -0500 Subject: [PATCH] Have `transform` take `&self` instead of `self` --- crates/floretta/src/lib.rs | 10 +++++----- crates/floretta/src/run.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/floretta/src/lib.rs b/crates/floretta/src/lib.rs index baba3a8..a9c70a7 100644 --- a/crates/floretta/src/lib.rs +++ b/crates/floretta/src/lib.rs @@ -98,13 +98,13 @@ impl Autodiff { } /// Transform a WebAssembly module using this configuration. - pub fn transform(self, wasm_module: &[u8]) -> Result, Error> { - self.runner.transform(self.config, wasm_module) + pub fn transform(&self, wasm_module: &[u8]) -> Result, Error> { + self.runner.transform(&self.config, wasm_module) } } trait Runner { - fn transform(&self, config: Config, wasm_module: &[u8]) -> Result, Error>; + fn transform(&self, config: &Config, wasm_module: &[u8]) -> Result, Error>; } // We make `Runner` a `trait` instead of just an `enum`, to facilitate dead code elimination when @@ -115,7 +115,7 @@ struct Validate; struct NoValidate; impl Runner for Validate { - fn transform(&self, config: Config, wasm_module: &[u8]) -> Result, Error> { + fn transform(&self, config: &Config, wasm_module: &[u8]) -> Result, Error> { let features = WasmFeatures::empty() | WasmFeatures::FLOATS; let validator = Validator::new_with_features(features); run::transform(validator, config, wasm_module) @@ -123,7 +123,7 @@ impl Runner for Validate { } impl Runner for NoValidate { - fn transform(&self, config: Config, wasm_module: &[u8]) -> Result, Error> { + fn transform(&self, config: &Config, wasm_module: &[u8]) -> Result, Error> { run::transform((), config, wasm_module) } } diff --git a/crates/floretta/src/run.rs b/crates/floretta/src/run.rs index fd3e643..197e549 100644 --- a/crates/floretta/src/run.rs +++ b/crates/floretta/src/run.rs @@ -20,7 +20,7 @@ use crate::{ pub fn transform( mut validator: impl ModuleValidator, - config: Config, + config: &Config, wasm_module: &[u8], ) -> Result, Error> { let mut types = TypeSection::new();