Skip to content

[FEAT]: Implement Generic Format and Display Utility for CairoΒ #202

@coxmars

Description

@coxmars

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.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions