Skip to content

Commit

Permalink
Merge pull request #33 from syntheticore/master
Browse files Browse the repository at this point in the history
Fix compilation under rustc 1.6.7 nightly
  • Loading branch information
alecmocatta authored Nov 25, 2022
2 parents 677b67f + 395eeb8 commit 28eb9f2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_traitobject"
version = "0.2.7"
version = "0.2.8"
license = "MIT OR Apache-2.0"
authors = ["Alec Mocatta <[email protected]>"]
categories = ["development-tools","encoding","rust-patterns","network-programming"]
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
endpoint: alecmocatta
default:
rust_toolchain: nightly
rust_lint_toolchain: nightly-2020-07-12
rust_lint_toolchain: nightly-2022-11-23
rust_flags: ''
rust_features: ';serde_closure'
rust_target_check: ''
Expand Down
48 changes: 24 additions & 24 deletions src/convenience.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
any, borrow::{Borrow, BorrowMut}, boxed, error, fmt, marker, ops::{self, Deref, DerefMut}, rc, sync
any, borrow::{Borrow, BorrowMut}, boxed, error, fmt, marker, marker::Tuple, ops::{self, Deref, DerefMut}, rc, sync
};

use super::{deserialize, serialize, Deserialize, Serialize};
Expand Down Expand Up @@ -91,22 +91,22 @@ impl<T: ?Sized> AsMut<boxed::Box<T>> for Box<T> {
}
impl<T: ?Sized> AsRef<T> for Box<T> {
fn as_ref(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> AsMut<T> for Box<T> {
fn as_mut(&mut self) -> &mut T {
&mut *self.0
&mut self.0
}
}
impl<T: ?Sized> Borrow<T> for Box<T> {
fn borrow(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> BorrowMut<T> for Box<T> {
fn borrow_mut(&mut self) -> &mut T {
&mut *self.0
&mut self.0
}
}
impl<T: ?Sized> From<boxed::Box<T>> for Box<T> {
Expand Down Expand Up @@ -147,7 +147,7 @@ impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> {
self.0.fmt(f)
}
}
impl<A, F: ?Sized> ops::FnOnce<A> for Box<F>
impl<A: Tuple, F: ?Sized> ops::FnOnce<A> for Box<F>
where
F: FnOnce<A>,
{
Expand All @@ -156,15 +156,15 @@ where
self.0.call_once(args)
}
}
impl<A, F: ?Sized> ops::FnMut<A> for Box<F>
impl<A: Tuple, 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>
impl<A: Tuple, F: ?Sized> ops::Fn<A> for Box<F>
where
F: Fn<A>,
{
Expand Down Expand Up @@ -222,22 +222,22 @@ impl<T: ?Sized> AsMut<rc::Rc<T>> for Rc<T> {
}
impl<T: ?Sized> AsRef<T> for Rc<T> {
fn as_ref(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> Borrow<T> for Rc<T> {
fn borrow(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> From<rc::Rc<T>> for Rc<T> {
fn from(t: rc::Rc<T>) -> Self {
Self(t)
}
}
impl<T: ?Sized> Into<rc::Rc<T>> for Rc<T> {
fn into(self) -> rc::Rc<T> {
self.0
impl<T: ?Sized> From<Rc<T>> for rc::Rc<T> {
fn from(v: Rc<T>) -> Self {
v.0
}
}
impl<T> From<T> for Rc<T> {
Expand Down Expand Up @@ -310,22 +310,22 @@ impl<T: ?Sized> AsMut<sync::Arc<T>> for Arc<T> {
}
impl<T: ?Sized> AsRef<T> for Arc<T> {
fn as_ref(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> Borrow<T> for Arc<T> {
fn borrow(&self) -> &T {
&*self.0
&self.0
}
}
impl<T: ?Sized> From<sync::Arc<T>> for Arc<T> {
fn from(t: sync::Arc<T>) -> Self {
Self(t)
}
}
impl<T: ?Sized> Into<sync::Arc<T>> for Arc<T> {
fn into(self) -> sync::Arc<T> {
self.0
impl<T: ?Sized> From<Arc<T>> for sync::Arc<T> {
fn from(v: Arc<T>) -> Self {
v.0
}
}
impl<T> From<T> for Arc<T> {
Expand Down Expand Up @@ -686,8 +686,8 @@ impl<'de> serde::de::Deserialize<'de> for boxed::Box<dyn Debug + Send + 'static>
/// A convenience trait implemented on all (de)serializable implementors of [`std::ops::FnOnce`].
///
/// It can be made into a trait object which is then (de)serializable.
pub trait FnOnce<Args>: ops::FnOnce<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args> FnOnce<Args> for T where T: ops::FnOnce<Args> + Serialize + Deserialize {}
pub trait FnOnce<Args: Tuple>: ops::FnOnce<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args: Tuple> FnOnce<Args> for T where T: ops::FnOnce<Args> + Serialize + Deserialize {}

impl<'a, Args, Output> AsRef<Self> for dyn FnOnce<Args, Output = Output> + 'a {
fn as_ref(&self) -> &Self {
Expand Down Expand Up @@ -743,8 +743,8 @@ impl<'de, Args: 'static, Output: 'static> serde::de::Deserialize<'de>
/// A convenience trait implemented on all (de)serializable implementors of [`std::ops::FnMut`].
///
/// It can be made into a trait object which is then (de)serializable.
pub trait FnMut<Args>: ops::FnMut<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args> FnMut<Args> for T where T: ops::FnMut<Args> + Serialize + Deserialize {}
pub trait FnMut<Args: Tuple>: ops::FnMut<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args: Tuple> FnMut<Args> for T where T: ops::FnMut<Args> + Serialize + Deserialize {}

impl<'a, Args, Output> AsRef<Self> for dyn FnMut<Args, Output = Output> + 'a {
fn as_ref(&self) -> &Self {
Expand Down Expand Up @@ -800,8 +800,8 @@ impl<'de, Args: 'static, Output: 'static> serde::de::Deserialize<'de>
/// A convenience trait implemented on all (de)serializable implementors of [`std::ops::Fn`].
///
/// It can be made into a trait object which is then (de)serializable.
pub trait Fn<Args>: ops::Fn<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args> Fn<Args> for T where T: ops::Fn<Args> + Serialize + Deserialize {}
pub trait Fn<Args: Tuple>: ops::Fn<Args> + Serialize + Deserialize {}
impl<T: ?Sized, Args: Tuple> Fn<Args> for T where T: ops::Fn<Args> + Serialize + Deserialize {}

impl<'a, Args, Output> AsRef<Self> for dyn Fn<Args, Output = Output> + 'a {
fn as_ref(&self) -> &Self {
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
arbitrary_self_types,
coerce_unsized,
fn_traits,
tuple_trait,
specialization,
unboxed_closures,
unsize
Expand Down Expand Up @@ -399,7 +400,7 @@ impl<T: Serialize + ?Sized + 'static> SerializerTrait<T> for Serializer<T> {
// See the [`relative`](https://github.com/alecmocatta/relative) crate
// for more information.
tup.serialize_element::<Vtable<T>>(&unsafe { Vtable::<T>::from(vtable) })?;
tup.serialize_element::<u64>(&<T as serialize::Sealed>::type_id(&t))?;
tup.serialize_element::<u64>(&<T as serialize::Sealed>::type_id(t))?;
tup.serialize_element::<SerializeErased<T>>(&SerializeErased(t))?;
tup.end()
}
Expand Down Expand Up @@ -497,7 +498,7 @@ impl<'de, T: Deserialize + ?Sized> serde::de::DeserializeSeed<'de> for Deseriali
where
D: serde::de::Deserializer<'de>,
{
let deserializer = &mut erased_serde::Deserializer::erase(deserializer);
let deserializer = &mut <dyn erased_serde::Deserializer>::erase(deserializer);
deserialize::deserialize_erased(self.0, deserializer).map_err(serde::de::Error::custom)
}
}
Expand Down

0 comments on commit 28eb9f2

Please sign in to comment.