Remove unused Display implementations

After the previous commit, nushell uses PrettyDebug and
PrettyDebugWithSource for our pretty-printed display output.

PrettyDebug produces a structured `pretty.rs` document rather than
writing directly into a fmt::Formatter, and types that implement
`PrettyDebug` have a convenience `display` method that produces a string
(to be used in situations where `Display` is needed for compatibility
with other traits, or where simple rendering is appropriate).
This commit is contained in:
Yehuda Katz
2019-11-25 10:07:20 -08:00
parent f70c6d5d48
commit 5fbea31d15
11 changed files with 182 additions and 165 deletions

View File

@ -10,8 +10,8 @@ use crate::TaggedDictBuilder;
use indexmap::IndexMap;
use log::trace;
use nu_source::Text;
use std::fmt;
#[derive(Debug)]
pub struct Scope {
it: Value,
vars: IndexMap<String, Value>,
@ -26,15 +26,6 @@ impl Scope {
}
}
impl fmt::Display for Scope {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_map()
.entry(&"$it", &format!("{:?}", self.it.value))
.entries(self.vars.iter().map(|(k, v)| (k, &v.value)))
.finish()
}
}
impl Scope {
pub(crate) fn empty() -> Scope {
Scope {
@ -177,7 +168,7 @@ fn evaluate_reference(
source: &Text,
tag: Tag,
) -> Result<Value, ShellError> {
trace!("Evaluating {} with Scope {}", name, scope);
trace!("Evaluating {:?} with Scope {:?}", name, scope);
match name {
hir::Variable::It(_) => Ok(scope.it.value.clone().into_value(tag)),
hir::Variable::Other(inner) => match inner.slice(source) {