diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-03-20 08:18:04 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-03-31 09:51:35 -0400 |
| commit | 27b7841bb1261fb2d94a0ed6f2ec0a146a44783d (patch) | |
| tree | 6061126fd745bbcf876a343da0fb2eeae7a66c07 | |
| parent | cdb10b884b3975dd897096e052f386f55cf0f4c9 (diff) | |
| download | rust-27b7841bb1261fb2d94a0ed6f2ec0a146a44783d.tar.gz rust-27b7841bb1261fb2d94a0ed6f2ec0a146a44783d.zip | |
Add blanket impls for references to the `Fn` traits.
| -rw-r--r-- | src/libcore/ops.rs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 862eb16d0bf..861892f0261 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1142,3 +1142,52 @@ pub trait FnOnce<Args> { /// This is called when the call operator is used. extern "rust-call" fn call_once(self, args: Args) -> Self::Output; } + +#[cfg(not(stage0))] +mod impls { + use marker::Sized; + use super::{Fn, FnMut, FnOnce}; + + impl<'a,A,F:?Sized> Fn<A> for &'a F + where F : Fn<A> + { + extern "rust-call" fn call(&self, args: A) -> F::Output { + (**self).call(args) + } + } + + impl<'a,A,F:?Sized> FnMut<A> for &'a F + where F : Fn<A> + { + extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { + (**self).call(args) + } + } + + impl<'a,A,F:?Sized> FnOnce<A> for &'a F + where F : Fn<A> + { + type Output = F::Output; + + extern "rust-call" fn call_once(self, args: A) -> F::Output { + (*self).call(args) + } + } + + impl<'a,A,F:?Sized> FnMut<A> for &'a mut F + where F : FnMut<A> + { + extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { + (*self).call_mut(args) + } + } + + impl<'a,A,F:?Sized> FnOnce<A> for &'a mut F + where F : FnMut<A> + { + type Output = F::Output; + extern "rust-call" fn call_once(mut self, args: A) -> F::Output { + (*self).call_mut(args) + } + } +} |
