diff --git a/src/config.rs b/src/config.rs index 790d9cc..3925506 100644 --- a/src/config.rs +++ b/src/config.rs @@ -59,9 +59,7 @@ pub fn read_config(repo: &Path) -> Result { lines.push(format!( "config = utils.merge(config, utils.load_toml {old_config:?})" )); - lines.push(format!( - "config = utils.merge(config, config.template_context)" - )) + lines.push("config = utils.merge(config, config.template_context)".to_string()) } lines.push("-- Changes can be added to the `config` object".to_owned()); lines.push("".to_owned()); diff --git a/src/repo/contents.rs b/src/repo/contents.rs index aaed1ba..a76a833 100644 --- a/src/repo/contents.rs +++ b/src/repo/contents.rs @@ -233,7 +233,7 @@ impl RootDirData { } fn read_lua(path: &Path, cfg: &SiloConfig) -> Result { - let lua = create_lua(&cfg)?; + let lua = create_lua(cfg)?; let cfg: Self = lua .from_value(lua.load(path).eval().describe("evaluating script")?) .describe("deserialize lua value")?; diff --git a/src/repo/hooks.rs b/src/repo/hooks.rs index 3a0a474..a6a397d 100644 --- a/src/repo/hooks.rs +++ b/src/repo/hooks.rs @@ -108,7 +108,7 @@ impl Hooks { impl HookScript { pub fn load(config: &SiloConfig, path: &Path) -> Result { - let lua = create_lua(&config)?; + let lua = create_lua(config)?; let module: OwnedTable = lua .load(path) .eval() diff --git a/src/scripting/utils_module.rs b/src/scripting/utils_module.rs index 006614a..7e57385 100644 --- a/src/scripting/utils_module.rs +++ b/src/scripting/utils_module.rs @@ -52,7 +52,7 @@ fn lua_merge<'a>(lua: &'a Lua, (a, b): (mlua::Value, mlua::Value)) -> Result(lua: &'a Lua, json_string: String) -> Result> { +fn lua_from_json(lua: &Lua, json_string: String) -> Result> { let toml_value: serde_json::Value = serde_json::from_str(&json_string).map_err(mlua::Error::external)?; @@ -60,31 +60,31 @@ fn lua_from_json<'a>(lua: &'a Lua, json_string: String) -> Result(lua: &'a Lua, path: String) -> Result> { +fn lua_load_json(lua: &Lua, path: String) -> Result> { let contents = fs::read_to_string(path)?; lua_from_json(lua, contents) } /// Parse a toml string into a lua value -fn lua_from_toml<'a>(lua: &'a Lua, toml_string: String) -> Result> { +fn lua_from_toml(lua: &Lua, toml_string: String) -> Result> { let toml_value: toml::Value = toml::from_str(&toml_string).map_err(mlua::Error::external)?; lua.to_value(&toml_value) } /// Reads a toml file and parses it as a lua value -fn lua_load_toml<'a>(lua: &'a Lua, path: String) -> Result> { +fn lua_load_toml(lua: &Lua, path: String) -> Result> { let contents = fs::read_to_string(path)?; lua_from_toml(lua, contents) } /// Returns the path to the given command -fn lua_which<'a>(_: &'a Lua, path: String) -> Result> { +fn lua_which(_: &Lua, path: String) -> Result> { Ok(which(path).ok().map(|p| p.to_string_lossy().into_owned())) } /// Creates a new executable that can be called with a variable number of args -fn lua_ext<'a>(lua: &'a Lua, program: String) -> Result> { +fn lua_ext(lua: &Lua, program: String) -> Result> { lua.create_function(move |_lua, args| { let exit_status = Command::new(&program) .args::, _>(args) @@ -110,7 +110,7 @@ struct CommandOutput { } /// Creates a new executable that can be called with a variable number of args -fn lua_ext_piped<'a>(lua: &'a Lua, program: String) -> Result> { +fn lua_ext_piped(lua: &Lua, program: String) -> Result> { lua.create_function(move |lua, args| { let cmd = Command::new(&program) .args::, _>(args)