You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
&str lifetime when variable is borrowed as argument (not captured) by closure #155998
This is #100002 and perhaps others: a hidden or wildcard lifetime in a closure argument types is always interpreted as "must take any lifetime", instead of "takes one specific lifetime".
Removing the &str (where the hidden lifetime "is") also works around the problem.
let c = |s:&mutOption<_>| *s = Some(str);let c = |s:&mut_| *s = Some(str);
Overriding default closure inference with a trait-bound identity function "funnel" also works around the problem.
fnfunnel<'s,F:Fn(&mutOption<&'sstr>)>(f:F) -> F{ f }let c = funnel(|s:&mutOption<&str>| *s = Some(str));
Activity
theemathas commentedon Apr 30, 2026
As a workaround, you can manually annotate the lifetime:
QuineDot commentedon Aug 22, 2026
This is #100002 and perhaps others: a hidden or wildcard lifetime in a closure argument types is always interpreted as "must take any lifetime", instead of "takes one specific lifetime".
Removing the
&str(where the hidden lifetime "is") also works around the problem.Overriding default closure inference with a trait-bound identity function "funnel" also works around the problem.