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

Please impl Default for watch::Sender<T> where T: Default #6623

Closed
joshtriplett opened this issue Jun 8, 2024 · 1 comment · Fixed by #6626
Closed

Please impl Default for watch::Sender<T> where T: Default #6623

joshtriplett opened this issue Jun 8, 2024 · 1 comment · Fixed by #6626
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync

Comments

@joshtriplett
Copy link

joshtriplett commented Jun 8, 2024

For types like watch::Sender<Option<...>>, it'd be convenient if Sender implemented Default if its contents did:

impl<T: Default> Default for Sender<T> {
    fn default() -> Self {
        Self::new(T::default())
    }
}

This would allow, for instance, using .or_default() in the HashMap/DashMap Entry API, rather than .or_insert_with(|| watch::Sender::new(None)).

@joshtriplett joshtriplett added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jun 8, 2024
@Darksonn Darksonn added E-help-wanted Call for participation: Help is requested to fix this issue. E-easy Call for participation: Experience needed to fix: Easy / not much M-sync Module: tokio/sync labels Jun 8, 2024
@Darksonn
Copy link
Contributor

Darksonn commented Jun 8, 2024

That sounds like a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants