Better debug display.
This commit is contained in:
parent
975bb3d6bf
commit
b78c6ddf62
16
src/ast.rs
16
src/ast.rs
@ -1102,7 +1102,7 @@ pub struct OpAssignment {
|
||||
/// # Volatile Data Structure
|
||||
///
|
||||
/// This type is volatile and may change.
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash, Default)]
|
||||
pub struct FnHash {
|
||||
/// Pre-calculated hash for a script-defined function ([`None`] if native functions only).
|
||||
script: Option<u64>,
|
||||
@ -1110,6 +1110,20 @@ pub struct FnHash {
|
||||
native: u64,
|
||||
}
|
||||
|
||||
impl fmt::Debug for FnHash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Some(script) = self.script {
|
||||
if script == self.native {
|
||||
write!(f, "({}=={})", script, self.native)
|
||||
} else {
|
||||
write!(f, "({}, {})", script, self.native)
|
||||
}
|
||||
} else {
|
||||
write!(f, "{}", self.native)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FnHash {
|
||||
/// Create a [`FnHash`] with only the native Rust hash.
|
||||
#[inline(always)]
|
||||
|
@ -2022,13 +2022,18 @@ pub struct NamespaceRef {
|
||||
|
||||
impl fmt::Debug for NamespaceRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(&self.path, f)?;
|
||||
|
||||
if let Some(index) = self.index {
|
||||
write!(f, " -> {}", index)
|
||||
} else {
|
||||
Ok(())
|
||||
write!(f, "{} -> ", index)?;
|
||||
}
|
||||
|
||||
f.write_str(
|
||||
&self
|
||||
.path
|
||||
.iter()
|
||||
.map(|Ident { name, .. }| name.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.join("::"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user