pub enum DebugValue {
Int(i32),
Float(f32),
Bool(bool),
Str(String),
Null,
List(Vec<String>),
DivertTarget(Option<String>),
Struct {
name: Option<String>,
fields: Vec<(String, DebugValue)>,
},
Handle {
kind: String,
id: u64,
},
Other(String),
}Expand description
A structured, read-only view of a runtime Value for the debugger’s
locals panel (docs/debugger-spec.md §3, D7/#3185).
Why structured, not another display string. DebugGlobal::value
is a display string (String) — that shape predates this ticket and
stays as-is (globals are out of D7’s scope, and changing an existing
public field is not “additive”). For locals, a display string is the
wrong shape to repeat: the issue’s own bar is that a debugger which can
only show "[list]" for a list value is not the target, and a plain
string can’t do better than that — a studio locals panel needs to tell
“this is a list with these members” from “this is a string that reads
like a list” to render either one correctly (or let a user expand a
struct’s fields, or distinguish a null from an empty string). So D7
exposes the value’s kind structurally for every kind the runtime
distinguishes that the issue calls out by name (int, float, string,
list, divert target, struct, handle), plus the common bool/null
cases that cost nothing extra to model — and falls back to the existing
[NameResolver::format_value] display string (DebugValue::Other)
for the long tail of kinds this ticket has no author-facing UI need to
special-case yet (closures, arrays, maps, weighted tables, function
refs, variable/temp pointers, fragment refs, vector/matrix/quaternion,
ranges, options, projections). Other is not a cop-out for the kinds
the issue named — those all get real variants below.
Variants§
Int(i32)
Float(f32)
Bool(bool)
Str(String)
Null
List(Vec<String>)
A list value’s member names, in list order (unresolvable items are
skipped, matching NameResolver::format_value’s existing behavior).
DivertTarget(Option<String>)
A divert-target value, resolved to its author-facing knot/stitch
path where possible. None when the target isn’t resolvable to a
named scope (matches format_value’s "-> ?" case).
Struct
A struct (Value::Record) value: its declared shape name (if
resolvable) and its fields, named and recursively structured.
Handle
A handle value (T1d): its manifest-declared kind name and the host-allocated token id.
Other(String)
Every other value kind’s existing display-string form
([NameResolver::format_value]) — see this enum’s own doc for why.
Trait Implementations§
Source§impl Clone for DebugValue
impl Clone for DebugValue
Source§fn clone(&self) -> DebugValue
fn clone(&self) -> DebugValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more