-
Notifications
You must be signed in to change notification settings - Fork 22
Closed as not planned
Labels
T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Description
Proposal
Problem statement
It is not possible to pass reference-counted closures to APIs that take Fn + 'static
or Fn + Clone
.
Motivation, use-cases
Many server APIs expect 'static
lifetimes but some logic may be implemented in a single closure that's reused in other places. Currently this would require moving captured values and invoking Clone
on the closure itself, which clones captured values.
Solution sketches
impl<A, F: Fn<A> + ?Sized> Fn<A> for Rc<F>
impl<A, F: Fn<A> + ?Sized> FnMut<A> for Rc<F>
impl<A, F: Fn<A> + ?Sized> FnOnce<A> for Rc<F>
impl<A, F: Fn<A> + ?Sized> Fn<A> for Arc<F>
impl<A, F: Fn<A> + ?Sized> FnMut<A> for Arc<F>
impl<A, F: Fn<A> + ?Sized> FnOnce<A> for Arc<F>
Alternative solutions: none.
Links and related work
Implementation: rust-lang/rust#105414
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
Metadata
Metadata
Assignees
Labels
T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries