Skip to content

feat: Introduce lazy_format for owned formatting arguments#9

Closed
WiSaGaN wants to merge 1 commit intomasterfrom
owned-formatting-lazy-format
Closed

feat: Introduce lazy_format for owned formatting arguments#9
WiSaGaN wants to merge 1 commit intomasterfrom
owned-formatting-lazy-format

Conversation

@WiSaGaN
Copy link
Owner

@WiSaGaN WiSaGaN commented May 21, 2025

Addresses the issue of needing an owned version of std::fmt::Arguments that can be stored or sent across threads.

This change introduces the lazy_format crate as the recommended solution.

Key changes:

  • Added lazy_format = "2.0.3" to Cargo.toml.
  • Included examples/owned_format.rs to demonstrate creating 'static formatting objects that capture owned data (e.g., String, numbers) and can be sent across threads.
  • Added integration tests in tests/owned_format_test.rs to verify the behavior, including data ownership and cross-thread usage.
  • Updated README.md with a new section "Handling Owned Formatting Arguments" explaining the problem and solution with lazy_format, complete with an example.

This provides a practical way to handle complex formatting scenarios where the lifetime of std::fmt::Arguments would be restrictive.

Addresses the issue of needing an owned version of `std::fmt::Arguments`
that can be stored or sent across threads.

This change introduces the `lazy_format` crate as the recommended
solution.

Key changes:
- Added `lazy_format = "2.0.3"` to Cargo.toml.
- Included `examples/owned_format.rs` to demonstrate creating
  `'static` formatting objects that capture owned data (e.g., String,
  numbers) and can be sent across threads.
- Added integration tests in `tests/owned_format_test.rs` to verify
  the behavior, including data ownership and cross-thread usage.
- Updated `README.md` with a new section "Handling Owned Formatting
  Arguments" explaining the problem and solution with `lazy_format`,
  complete with an example.

This provides a practical way to handle complex formatting scenarios
where the lifetime of `std::fmt::Arguments` would be restrictive.
@WiSaGaN WiSaGaN closed this May 22, 2025
@WiSaGaN WiSaGaN deleted the owned-formatting-lazy-format branch May 22, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant