Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for write! macro to Serializer #2689

Open
nyurik opened this issue Feb 4, 2024 · 0 comments
Open

Add support for write! macro to Serializer #2689

nyurik opened this issue Feb 4, 2024 · 0 comments

Comments

@nyurik
Copy link
Contributor

nyurik commented Feb 4, 2024

The write!($dst, $args+) macro wraps a call to $dst.write_fmt(format_args!($($arg)*)) - making it ergonomic to use formatted output on anything "writable" -- write!(dst, "foo={foo}"). It seems serde does not support write! because it does not have write_fmt, even though it has almost identical collect_str. Even its documentation implies similar usage pattern.

Would it be possible to add another write_fmt fn to the Serializer to make this usecase easier? In theory, if collect_str was called write_fmt, it would have worked out of the box, so a default Trait impl to simply forward the call should be possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant