harbor run -t openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-7562harbor download openthoughts/tasktrove-exp-rpt-stack-rust-v2-stack-rust-7562Task Description: Implement Type Printer Functionality in Rust
You are required to implement the functionality for printing various Abstract Syntax Tree (AST) types as defined in the Rust code provided. This will involve enhancing the Printer struct and the associated write methods to handle different types of AST nodes properly. The functionality must meet the specifications outlined in the tests to ensure they pass successfully.
Implement the following AST printing functionality:
Any, String, Number, and Boolean print correctly as "any", "string", "number", and "boolean" respectively." | ". For example, an AST::Union containing AST::String and AST::Number should be printed as "string | number".AST::ReadOnlyArray to format it as "$ReadOnlyArray<type>".AST::Nullable, ensure it prints a type as "?" followed by the inner type. If the inner type is a union with more than one member, it must be enclosed in parentheses, e.g., "?(string | number)".AST::ExactObject should print properties formatted with their keys, types, and modifiers (optional or read-only), enclosed within {| |}.AST::InexactObject should print similar properties but be enclosed within { ... }.AST::OtherEnumValue with associated comments such that it prints "%other" with a preceding comment explaining its presence.Formatting and Indentation: The printed output must follow the specific indentation and formatting conventions, ensuring that:
Implement appropriate error handling: Ensure that the write methods handle potential errors in writing to the output.
Place the implemented functionality in the /app/ directory of your project, specifically focusing on enhancing the existing code in the provided module.
The implemented features must ensure that all the tests in the #[cfg(test)] module pass successfully. Please refer to the tests for expected outputs.