mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-28 13:04:47 +00:00
uv-pep508: add Debug impl for MarkerTree's actual internal representation
I found myself using this more verbose representation to double check that there wasn't any other "hidden" state occurring in markers, and that the graph debug display wasn't hiding anything that I was missing.
This commit is contained in:
parent
d652b0c024
commit
3df883c95d
1 changed files with 27 additions and 0 deletions
|
@ -1238,6 +1238,15 @@ impl MarkerTree {
|
||||||
MarkerTreeDebugGraph { marker: self }
|
MarkerTreeDebugGraph { marker: self }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Formats a [`MarkerTree`] in its "raw" representation.
|
||||||
|
///
|
||||||
|
/// This is useful for debugging when one wants to look at a
|
||||||
|
/// representation of a `MarkerTree` that is precisely identical
|
||||||
|
/// to its internal representation.
|
||||||
|
pub fn debug_raw(&self) -> MarkerTreeDebugRaw<'_> {
|
||||||
|
MarkerTreeDebugRaw { marker: self }
|
||||||
|
}
|
||||||
|
|
||||||
fn fmt_graph(&self, f: &mut fmt::Formatter<'_>, level: usize) -> fmt::Result {
|
fn fmt_graph(&self, f: &mut fmt::Formatter<'_>, level: usize) -> fmt::Result {
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
MarkerTreeKind::True => return write!(f, "true"),
|
MarkerTreeKind::True => return write!(f, "true"),
|
||||||
|
@ -1341,6 +1350,24 @@ impl<'a> fmt::Debug for MarkerTreeDebugGraph<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Formats a [`MarkerTree`] using its raw internals.
|
||||||
|
///
|
||||||
|
/// This is very verbose and likely only useful if you're working
|
||||||
|
/// on the internals of this crate.
|
||||||
|
///
|
||||||
|
/// This type is created by the [`MarkerTree::debug_raw`] routine.
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct MarkerTreeDebugRaw<'a> {
|
||||||
|
marker: &'a MarkerTree,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for MarkerTreeDebugRaw<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
let node = INTERNER.shared.node(self.marker.0);
|
||||||
|
f.debug_tuple("MarkerTreeDebugRaw").field(node).finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The underlying kind of an arbitrary node in a [`MarkerTree`].
|
/// The underlying kind of an arbitrary node in a [`MarkerTree`].
|
||||||
///
|
///
|
||||||
/// A marker tree is represented as an algebraic decision tree with two terminal nodes
|
/// A marker tree is represented as an algebraic decision tree with two terminal nodes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue