mirror of
https://github.com/nushell/nushell
synced 2024-12-29 06:23:11 +00:00
ab915f1c44
This reverts commit bee7c5639c
.
28 lines
595 B
Rust
28 lines
595 B
Rust
use crate::prelude::*;
|
|
use std::fmt;
|
|
|
|
pub struct Debuggable<'a, T: ToDebug> {
|
|
inner: &'a T,
|
|
source: &'a str,
|
|
}
|
|
|
|
impl<T: ToDebug> fmt::Display for Debuggable<'_, T> {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
self.inner.fmt_debug(f, self.source)
|
|
}
|
|
}
|
|
|
|
pub trait HasTag {
|
|
fn tag(&self) -> Tag;
|
|
}
|
|
|
|
pub trait ToDebug: Sized {
|
|
fn debug<'a>(&'a self, source: &'a str) -> Debuggable<'a, Self> {
|
|
Debuggable {
|
|
inner: self,
|
|
source,
|
|
}
|
|
}
|
|
|
|
fn fmt_debug(&self, f: &mut fmt::Formatter, source: &str) -> fmt::Result;
|
|
}
|