From 1d86c4537ea9e693e497407972b23d47bab53969 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 12 Aug 2022 17:30:17 +0300 Subject: refactor(tvix/eval): use `write!` macro instead of `f.write_fmt` grfn pointed out in cl/6082 that this is actually the desugaring of the write! macro, so it doesn't make sense to write it out. Change-Id: If7c055b042ad22b034722aec1eaadba92736d684 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6180 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: grfn --- tvix/eval/src/value/attrs.rs | 6 +++--- tvix/eval/src/value/mod.rs | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index 2efeaad413..1b76eb1966 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -77,13 +77,13 @@ impl Display for NixAttrs { match &self.0 { AttrsRep::KV { name, value } => { - f.write_fmt(format_args!("name = {}; ", name))?; - f.write_fmt(format_args!("value = {}; ", value))?; + write!(f, "name = {}; ", name)?; + write!(f, "value = {}; ", value)?; } AttrsRep::Map(map) => { for (name, value) in map.iter() { - f.write_fmt(format_args!("{} = {}; ", name.ident_str(), value))?; + write!(f, "{} = {}; ", name.ident_str(), value)?; } } diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index e9fdc40ac5..3889a79835 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -104,17 +104,16 @@ impl Display for Value { Value::Null => f.write_str("null"), Value::Bool(true) => f.write_str("true"), Value::Bool(false) => f.write_str("false"), - Value::Integer(num) => f.write_fmt(format_args!("{}", num)), + Value::Integer(num) => write!(f, "{}", num), Value::String(s) => s.fmt(f), Value::Attrs(attrs) => attrs.fmt(f), Value::List(list) => list.fmt(f), // Nix prints floats with a maximum precision of 5 digits // only. - Value::Float(num) => f.write_fmt(format_args!( - "{}", - format!("{:.5}", num).trim_end_matches(['.', '0']) - )), + Value::Float(num) => { + write!(f, "{}", format!("{:.5}", num).trim_end_matches(['.', '0'])) + } // internal types Value::AttrPath(_) => f.write_str("internal[attrpath]"), -- cgit 1.4.1