savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
154 stars 12 forks source link

Add `TraceData`, a standard trait for traceable data structures. #431

Closed jemc closed 1 year ago

jemc commented 1 year ago

Types can now implement a trace_data function that takes a TraceData.Observer as an argument, using it cooperatively to walk it through any properties it wishes to trace.

The TraceData.Observer trait can be implemented by any observer which wishes to be able to accumulate state during tracing. Some examples may be printing data, measuring data, or serializing to various formats that are focused on the same kinds of data primitives.

Inspect can now use tracing to print the data in complex nested objects. Any type which implements TraceData can now be printed in this way.