mirror of
https://github.com/m-lamonaca/json-to-env.git
synced 2025-04-05 10:26:40 +00:00
do not clone EnvVar
fields for Display
This commit is contained in:
parent
709aa82b3e
commit
5983d9b587
1 changed files with 12 additions and 8 deletions
20
src/main.rs
20
src/main.rs
|
@ -109,14 +109,18 @@ impl EnvVar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for EnvVar {
|
impl Display for EnvVar {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let key = self.name.clone();
|
match self.value {
|
||||||
match self.value.clone() {
|
Value::Null => write!(fmt, "{key}=null", key = self.name),
|
||||||
Value::Null => write!(f, "{key}=null"),
|
Value::Bool(bool) => write!(fmt, "{key}={bool}", key = self.name),
|
||||||
Value::Bool(bool) => write!(f, "{key}={bool}",),
|
Value::Number(ref number) => write!(fmt, "{key}={number}", key = self.name),
|
||||||
Value::Number(number) => write!(f, "{key}={number}"),
|
Value::String(ref string) => write!(
|
||||||
Value::String(string) => write!(f, r#"{key}="{}""#, string.replace('"', r#"\""#)),
|
fmt,
|
||||||
_ => write!(f, ""),
|
r#"{key}="{value}""#,
|
||||||
|
key = self.name,
|
||||||
|
value = string.replace('"', r#"\""#)
|
||||||
|
),
|
||||||
|
_ => write!(fmt, ""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue