Skip to content

Commit

Permalink
impl Fn/Mut/Once for convenience::Box
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed Jul 23, 2019
1 parent 79a02aa commit e29c2a9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
25 changes: 25 additions & 0 deletions src/convenience.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,31 @@ impl<T: Serialize + Deserialize + fmt::Display + ?Sized> fmt::Display for Box<T>
self.0.fmt(f)
}
}
impl<A, F: ?Sized> ops::FnOnce<A> for Box<F>
where
F: FnOnce<A>,
{
type Output = F::Output;
extern "rust-call" fn call_once(self, args: A) -> Self::Output {
self.0.call_once(args)
}
}
impl<A, F: ?Sized> ops::FnMut<A> for Box<F>
where
F: FnMut<A>,
{
extern "rust-call" fn call_mut(&mut self, args: A) -> Self::Output {
self.0.call_mut(args)
}
}
impl<A, F: ?Sized> ops::Fn<A> for Box<F>
where
F: Fn<A>,
{
extern "rust-call" fn call(&self, args: A) -> Self::Output {
self.0.call(args)
}
}
impl<T: Serialize + Deserialize + ?Sized + 'static> serde::ser::Serialize for Box<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@
#![doc(html_root_url = "https://docs.rs/serde_traitobject/0.1.3")]
#![feature(
unboxed_closures,
core_intrinsics,
coerce_unsized,
unsize,
specialization
core_intrinsics,
fn_traits,
specialization,
unboxed_closures,
unsize
)]
#![warn(
missing_copy_implementations,
Expand Down

0 comments on commit e29c2a9

Please sign in to comment.