Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,29 @@ impl<T: ?Sized> Deref for Rc<T> {
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> Fn<Args> for Rc<F> {
extern "rust-call" fn call(&self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(self, args)
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> FnMut<Args> for Rc<F> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(self, args)
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> FnOnce<Args> for Rc<F> {
type Output = F::Output;

extern "rust-call" fn call_once(self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(&self, args)
}
}

#[unstable(feature = "receiver_trait", issue = "none")]
impl<T: ?Sized> Receiver for Rc<T> {}

Expand Down
23 changes: 23 additions & 0 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,29 @@ impl<T: ?Sized> Deref for Arc<T> {
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> Fn<Args> for Arc<F> {
extern "rust-call" fn call(&self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(self, args)
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> FnMut<Args> for Arc<F> {
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(self, args)
}
}

#[stable(feature = "rc_closure_impls", since = "CURRENT_RUSTC_VERSION")]
impl<Args, F: Fn<Args> + ?Sized> FnOnce<Args> for Arc<F> {
type Output = F::Output;

extern "rust-call" fn call_once(self, args: Args) -> Self::Output {
<F as Fn<Args>>::call(&self, args)
}
}

#[unstable(feature = "receiver_trait", issue = "none")]
impl<T: ?Sized> Receiver for Arc<T> {}

Expand Down