Skip to main content

wdl_format/element/
node.rs

1//! A wrapper for formatting [`Node`]s.
2
3use wdl_ast::Element;
4use wdl_ast::Node;
5
6use crate::element::FormatElement;
7use crate::element::collate;
8
9/// An extension trait for formatting [`Node`]s.
10pub trait AstNodeFormatExt {
11    /// Consumes `self` and returns the [`Node`] as a [`FormatElement`].
12    fn into_format_element(self) -> FormatElement;
13}
14
15impl AstNodeFormatExt for Node {
16    fn into_format_element(self) -> FormatElement
17    where
18        Self: Sized,
19    {
20        let children = collate(&self);
21        FormatElement::new(Element::Node(self), children)
22    }
23}