feat: Introduce lazy_format for owned formatting arguments#9
Closed
feat: Introduce lazy_format for owned formatting arguments#9
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the issue of needing an owned version of
std::fmt::Argumentsthat can be stored or sent across threads.This change introduces the
lazy_formatcrate as the recommended solution.Key changes:
lazy_format = "2.0.3"to Cargo.toml.examples/owned_format.rsto demonstrate creating'staticformatting objects that capture owned data (e.g., String, numbers) and can be sent across threads.tests/owned_format_test.rsto verify the behavior, including data ownership and cross-thread usage.README.mdwith a new section "Handling Owned Formatting Arguments" explaining the problem and solution withlazy_format, complete with an example.This provides a practical way to handle complex formatting scenarios where the lifetime of
std::fmt::Argumentswould be restrictive.