Skip to content

Commit 404b60b

Browse files
committed
Constify impl Fn* &(mut) Fn*
1 parent c97922d commit 404b60b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

library/core/src/ops/function.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,29 +250,32 @@ pub trait FnOnce<Args> {
250250

251251
mod impls {
252252
#[stable(feature = "rust1", since = "1.0.0")]
253-
impl<A, F: ?Sized> Fn<A> for &F
253+
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "none")]
254+
impl<A, F: ?Sized> const Fn<A> for &F
254255
where
255-
F: Fn<A>,
256+
F: ~const Fn<A>,
256257
{
257258
extern "rust-call" fn call(&self, args: A) -> F::Output {
258259
(**self).call(args)
259260
}
260261
}
261262

262263
#[stable(feature = "rust1", since = "1.0.0")]
263-
impl<A, F: ?Sized> FnMut<A> for &F
264+
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "none")]
265+
impl<A, F: ?Sized> const FnMut<A> for &F
264266
where
265-
F: Fn<A>,
267+
F: ~const Fn<A>,
266268
{
267269
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
268270
(**self).call(args)
269271
}
270272
}
271273

272274
#[stable(feature = "rust1", since = "1.0.0")]
273-
impl<A, F: ?Sized> FnOnce<A> for &F
275+
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "none")]
276+
impl<A, F: ?Sized> const FnOnce<A> for &F
274277
where
275-
F: Fn<A>,
278+
F: ~const Fn<A>,
276279
{
277280
type Output = F::Output;
278281

@@ -282,19 +285,21 @@ mod impls {
282285
}
283286

284287
#[stable(feature = "rust1", since = "1.0.0")]
285-
impl<A, F: ?Sized> FnMut<A> for &mut F
288+
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "none")]
289+
impl<A, F: ?Sized> const FnMut<A> for &mut F
286290
where
287-
F: FnMut<A>,
291+
F: ~const FnMut<A>,
288292
{
289293
extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output {
290294
(*self).call_mut(args)
291295
}
292296
}
293297

294298
#[stable(feature = "rust1", since = "1.0.0")]
295-
impl<A, F: ?Sized> FnOnce<A> for &mut F
299+
#[rustc_const_unstable(feature = "const_fn_trait_ref_impls", issue = "none")]
300+
impl<A, F: ?Sized> const FnOnce<A> for &mut F
296301
where
297-
F: FnMut<A>,
302+
F: ~const FnMut<A>,
298303
{
299304
type Output = F::Output;
300305
extern "rust-call" fn call_once(self, args: A) -> F::Output {

0 commit comments

Comments
 (0)