Skip to main content

debug_display

Function debug_display 

Source
pub fn debug_display(interp: &Interp<'_>, value: &Value) -> String
Expand description

How print renders a value: the reference’s JS_PrintValue.

This is not ToString. print({a:1}) shows { a: 1 } and print([1]) shows [ 1 ], because the host printer dumps the structure rather than converting it. The format is reproduced closely because the test suite compares output text:

  • an empty container has two spaces inside its brackets — [ ], { };
  • nesting stops at depth 2 and prints [Array] / [Object];
  • a cycle prints [circular N] with N the stack index of the object;
  • an array with an interior hole prints as idx: value pairs, while holes at the end print as <N empty item(s)>;
  • a string is quoted inside a container but raw at the top level, which is why print("x") and print(["x"]) differ.