Make get_env_var return a reference to a Value (#13987)

# Description
Title says it all, changes `EngineState::get_env_var` to return a
`Option<&'a Value>` instead of an owned `Option<Value>`. This avoids
some unnecessary clones.

I also made a similar change to the `PluginExecutionContext` trait.
This commit is contained in:
Ian Manske
2024-10-02 04:05:48 -07:00
committed by GitHub
parent f03ba6793e
commit 157494e803
17 changed files with 74 additions and 51 deletions

View File

@@ -348,7 +348,7 @@ pub fn nu_repl() {
.coerce_str()
.unwrap_or_else(|err| outcome_err(&engine_state, &err));
let _ = std::env::set_current_dir(path.as_ref());
engine_state.add_env_var("PWD".into(), cwd);
engine_state.add_env_var("PWD".into(), cwd.clone());
}
top_stack = Arc::new(Stack::with_changes_from_child(top_stack, stack));
}