Skip to content

tracing_core::dispatcher::get_default() takes a FnMut when it should take a FnOnce #1653

Open
@lilyball

Description

@lilyball

Bug Report

Version

tracing-core v0.1.21
Also current 0.2.0 as documented on tracing.rs

Crates

tracing-core

Description

tracing_core::dispatcher::get_default() (and consequently tracing::dispatcher::get_default()) takes a FnMut argument, which it executes exactly once. The use of FnMut here is unnecessarily restrictive.

Proposal

Change it to take an FnOnce. This is a backwards-compatible change (as every FnMut is also an FnOnce). The implementation can just wrap it in an Option and use take() to pull out the function; this is safe as the function will be called exactly once for every possible code path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    crate/coreRelated to the `tracing-core` crategood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions