-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Labels
Description
Implement Generic Format and Display Utility for Cairo
π Description
Create a generic format and display utility in Cairo that simplifies the implementation of the Display and Debug traits for custom data types. As the Cairo Book explains, custom data types require explicit implementation of these traits to be usable with print! and println! macros. This utility will reduce the boilerplate code needed for these implementations through a set of macros and helper functions.
β Acceptance Criteria
Implement a generic Formattable trait that serves as a foundation for both Display and Debug implementations.
Create a macro system that automatically derives Display and Debug implementations:
- Provide a derive_fmt! macro for structs that generates the required fmt method with minimal input.
- Implement collection formatting through a derive_collection_fmt! macro for types like Array and Span.
- Create implementations for primitive types that match Cairo's standard behavior.
Implement utility functions that work with Cairo's Formatter struct to simplify common formatting patterns:
- Helper for struct field formatting
- Support for tabular data presentation
- Utilities for collection formatting
- Ensure the utility is compatible with Cairo's existing write! and writeln! macros.
- Write comprehensive tests that demonstrate the improvements over manual implementations.
π References
π Additional Notes
- β Read our guidelines before applying.
Reactions are currently unavailable