diff --git a/codex-rs/core/src/environment_context.rs b/codex-rs/core/src/environment_context.rs
index 75c6009b7b..35e7fc1309 100644
--- a/codex-rs/core/src/environment_context.rs
+++ b/codex-rs/core/src/environment_context.rs
@@ -158,10 +158,11 @@ impl EnvironmentContext {
/// ...
///
/// ```
- pub fn serialize_to_xml(self) -> String {
+ pub fn serialize_to_xml(&self) -> String {
let mut lines = vec![ENVIRONMENT_CONTEXT_OPEN_TAG.to_string()];
- if let Some(cwd) = self.cwd {
- lines.push(format!(" {}", cwd.to_string_lossy()));
+ if let Some(cwd) = self.cwd.as_ref() {
+ let cwd = cwd.to_string_lossy();
+ lines.push(format!(" {cwd}"));
}
if let Some(approval_policy) = self.approval_policy {
lines.push(format!(
@@ -171,33 +172,30 @@ impl EnvironmentContext {
if let Some(sandbox_mode) = self.sandbox_mode {
lines.push(format!(" {sandbox_mode}"));
}
- if let Some(network_access) = self.network_access {
+ if let Some(network_access) = self.network_access.as_ref() {
lines.push(format!(
" {network_access}"
));
}
- if let Some(writable_roots) = self.writable_roots {
+ if let Some(writable_roots) = self.writable_roots.as_ref() {
lines.push(" ".to_string());
for writable_root in writable_roots {
- lines.push(format!(
- " {}",
- writable_root.to_string_lossy()
- ));
+ let writable_root = writable_root.to_string_lossy();
+ lines.push(format!(" {writable_root}"));
}
lines.push(" ".to_string());
}
- if let Some(shell) = self.shell
+ if let Some(shell) = self.shell.as_ref()
&& let Some(shell_name) = shell.name()
{
lines.push(format!(" {shell_name}"));
}
- if let Some(operating_system) = self.operating_system {
+ if let Some(operating_system) = self.operating_system.as_ref() {
lines.push(" ".to_string());
- lines.push(format!(" {}", operating_system.name));
- lines.push(format!(
- " {}",
- operating_system.version
- ));
+ let name = operating_system.name.as_str();
+ lines.push(format!(" {name}"));
+ let version = operating_system.version.as_str();
+ lines.push(format!(" {version}"));
if let Some(is_wsl) = operating_system.is_likely_windows_subsystem_for_linux {
lines.push(format!(
" {is_wsl}"