do not clone EnvVar fields for Display

This commit is contained in:
Marcello 2024-02-14 23:32:57 +01:00
parent 709aa82b3e
commit 5983d9b587
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk

View file

@ -109,14 +109,18 @@ impl EnvVar {
}
impl Display for EnvVar {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let key = self.name.clone();
match self.value.clone() {
Value::Null => write!(f, "{key}=null"),
Value::Bool(bool) => write!(f, "{key}={bool}",),
Value::Number(number) => write!(f, "{key}={number}"),
Value::String(string) => write!(f, r#"{key}="{}""#, string.replace('"', r#"\""#)),
_ => write!(f, ""),
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.value {
Value::Null => write!(fmt, "{key}=null", key = self.name),
Value::Bool(bool) => write!(fmt, "{key}={bool}", key = self.name),
Value::Number(ref number) => write!(fmt, "{key}={number}", key = self.name),
Value::String(ref string) => write!(
fmt,
r#"{key}="{value}""#,
key = self.name,
value = string.replace('"', r#"\""#)
),
_ => write!(fmt, ""),
}
}
}