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

tracing-core: relax get_default's argument to FnOnce #2292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jswrenn
Copy link
Contributor

@jswrenn jswrenn commented Aug 30, 2022

Motivation

This change increases the flexibility of get_default, by relaxing the bound on its argument from FnMut to FnOnce.

Solution

It was already the case that get_default's argument was only invoked at-most once. However, the compiler could not prove this, and thus required that the argument be FnMut. This commit introduces UnsafeFnMut, a type that wraps an FnOnce and provides an unsafe interface for invoking it in cases where the compiler cannot otherwise prove that it's only invoked at-most once.

This change increases the flexibility of `get_default`.

It was already the case that `get_default`'s argument was only
invoked at-most once. However, the compiler could not prove this,
and thus required that the argument be `FnMut`. This commit
introduces `UnsafeFnMut`, a type that wraps an `FnOnce` and
provides an unsafe interface for invoking it in cases where the
compiler cannot otherwise prove that it's only invoked at-most
once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant