diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-07-03 09:14:56 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-07-08 14:36:43 +0000 |
| commit | 543c860ea6c78e77b0a12685e066a74fe26dc301 (patch) | |
| tree | bfb7730feeff599555fd16815236c360a3aebd8e /library/core/src/ops/function.rs | |
| parent | 2783fc43fd13a669f314742890acd64200ad0bbf (diff) | |
| download | rust-543c860ea6c78e77b0a12685e066a74fe26dc301.tar.gz rust-543c860ea6c78e77b0a12685e066a74fe26dc301.zip | |
Constify `Fn*` traits
Diffstat (limited to 'library/core/src/ops/function.rs')
| -rw-r--r-- | library/core/src/ops/function.rs | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index df48c104410..763b60d88e5 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -72,7 +72,8 @@ use crate::marker::Tuple; )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] -// FIXME(const_trait_impl) #[const_trait] +#[const_trait] +#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] pub trait Fn<Args: Tuple>: FnMut<Args> { /// Performs the call operation. #[unstable(feature = "fn_traits", issue = "29625")] @@ -159,7 +160,8 @@ pub trait Fn<Args: Tuple>: FnMut<Args> { )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] -// FIXME(const_trait_impl) #[const_trait] +#[const_trait] +#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] pub trait FnMut<Args: Tuple>: FnOnce<Args> { /// Performs the call operation. #[unstable(feature = "fn_traits", issue = "29625")] @@ -238,7 +240,8 @@ pub trait FnMut<Args: Tuple>: FnOnce<Args> { )] #[fundamental] // so that regex can rely that `&str: !FnMut` #[must_use = "closures are lazy and do nothing unless called"] -// FIXME(const_trait_impl) #[const_trait] +#[const_trait] +#[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] pub trait FnOnce<Args: Tuple> { /// The returned type after the call operator is used. #[lang = "fn_once_output"] @@ -254,9 +257,10 @@ mod impls { use crate::marker::Tuple; #[stable(feature = "rust1", since = "1.0.0")] - impl<A: Tuple, F: ?Sized> Fn<A> for &F + #[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] + impl<A: Tuple, F: ?Sized> const Fn<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { extern "rust-call" fn call(&self, args: A) -> F::Output { (**self).call(args) @@ -264,9 +268,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A: Tuple, F: ?Sized> FnMut<A> for &F + #[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] + impl<A: Tuple, F: ?Sized> const FnMut<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { (**self).call(args) @@ -274,9 +279,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A: Tuple, F: ?Sized> FnOnce<A> for &F + #[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] + impl<A: Tuple, F: ?Sized> const FnOnce<A> for &F where - F: Fn<A>, + F: ~const Fn<A>, { type Output = F::Output; @@ -286,9 +292,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A: Tuple, F: ?Sized> FnMut<A> for &mut F + #[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] + impl<A: Tuple, F: ?Sized> const FnMut<A> for &mut F where - F: FnMut<A>, + F: ~const FnMut<A>, { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { (*self).call_mut(args) @@ -296,9 +303,10 @@ mod impls { } #[stable(feature = "rust1", since = "1.0.0")] - impl<A: Tuple, F: ?Sized> FnOnce<A> for &mut F + #[rustc_const_unstable(feature = "const_trait_impl", issue = "67792")] + impl<A: Tuple, F: ?Sized> const FnOnce<A> for &mut F where - F: FnMut<A>, + F: ~const FnMut<A>, { type Output = F::Output; extern "rust-call" fn call_once(self, args: A) -> F::Output { |
