Add blanket impls for references to the Fn
traits.
This commit is contained in:
parent
cdb10b884b
commit
27b7841bb1
1 changed files with 49 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue