diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-08-31 16:25:12 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-31 16:25:12 +0200 |
| commit | 7f48e8fe6668c5b2fdc62cc70e6bcffb744f411c (patch) | |
| tree | 6ec437098d9f6df511cfbc0805ac51af288c4eec /src/eval/function.rs | |
| parent | 3481d8cc81a2b3a14118869c7f0ffe204ff3efc8 (diff) | |
Make user-facing "debug" representation use Debug instead of Display
Diffstat (limited to 'src/eval/function.rs')
| -rw-r--r-- | src/eval/function.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/eval/function.rs b/src/eval/function.rs index 57364d11..c45ac7ba 100644 --- a/src/eval/function.rs +++ b/src/eval/function.rs @@ -1,4 +1,4 @@ -use std::fmt::{self, Debug, Display, Formatter, Write}; +use std::fmt::{self, Debug, Formatter, Write}; use std::rc::Rc; use super::{Cast, EvalContext, Str, Value}; @@ -40,12 +40,6 @@ impl Function { impl Debug for Function { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - f.debug_struct("Function").field("name", &self.0.name).finish() - } -} - -impl Display for Function { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.write_str("<function")?; if let Some(name) = self.name() { f.write_char(' ')?; @@ -63,7 +57,7 @@ impl PartialEq for Function { } /// Evaluated arguments to a function. -#[derive(Debug, Clone, PartialEq)] +#[derive(Clone, PartialEq)] pub struct Arguments { /// The span of the whole argument list. pub span: Span, @@ -72,7 +66,7 @@ pub struct Arguments { } /// An argument to a function call: `12` or `draw: false`. -#[derive(Debug, Clone, PartialEq)] +#[derive(Clone, PartialEq)] pub struct Argument { /// The span of the whole argument. pub span: Span, @@ -192,15 +186,11 @@ impl Arguments { } } -impl Display for Arguments { +impl Debug for Arguments { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.write_char('(')?; for (i, arg) in self.items.iter().enumerate() { - if let Some(name) = &arg.name { - f.write_str(name)?; - f.write_str(": ")?; - } - Display::fmt(&arg.value.v, f)?; + arg.fmt(f)?; if i + 1 < self.items.len() { f.write_str(", ")?; } @@ -209,6 +199,16 @@ impl Display for Arguments { } } +impl Debug for Argument { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + if let Some(name) = &self.name { + f.write_str(name)?; + f.write_str(": ")?; + } + Debug::fmt(&self.value.v, f) + } +} + dynamic! { Arguments: "arguments", } |
