Skip to content

Implement Default for CompactFormatter #1268

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

Merged
merged 1 commit into from
Aug 19, 2025
Merged

Conversation

SOF3
Copy link
Contributor

@SOF3 SOF3 commented Jul 6, 2025

This allows libraries to provide an API like

impl<W, F> SomeWrapper<W, F> {
    pub fn new_serializer(writer: W) -> impl serde::Serializer
    where
        F: Default,
    {
        serde_json::Serializer::with_formatter(writer, F::default())
    }
}

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit 8be6647 into serde-rs:master Aug 19, 2025
16 checks passed
@SOF3 SOF3 deleted the compact-default branch August 19, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants