pub trait ToCursors {
// Required method
fn to_cursors(&self, s: &mut impl CursorSink);
}
Expand description
This trait allows AST nodes to decompose themselves back into a set of (ordered) Cursors.
This trait is useful to implement because downstream operations can use it to reconstruct source text from Nodes, including after mutating Nodes, such as transforming them (e.g. minification or formatting).
Nodes that implement this trait should call s.append()
in the order that those Cursors were parsed,
unless there’s a good reason not to. Some good reasons not to:
- The specification supplies a specific grammar order.
- Doing so would require creating many intermediary enums or structs.
Required Methods§
fn to_cursors(&self, s: &mut impl CursorSink)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.