Skip to main content

inspect

Function inspect 

Source
pub fn inspect(value: any) -> string
Available on crate feature extended only.
Expand description

Renders any value as a human-readable string. Extended library — feature extended. In the spirit of the widely used inspect.lua.

Tables are rendered recursively with indentation and a deterministic key order; cycles are detected and shown as <cycle ...>; strings are quoted; a table with a __tostring metamethod is rendered through it.

§Examples

print(inspect({1, "two", nested = { ok = true }}))
--> {
-->   1,
-->   "two",
-->   nested = {
-->     ok = true
-->   }
--> }
local t = {}; t.me = t
print(inspect(t))    --> { me = <cycle table: 0x...> }

§See also

tostring(), print()